idddlZddlZddlmZddlmZmZddlmZ e n#e $re e fZ YnwxYwdZ GddZGd d eeZGd d eeZd ZdS)N)dedent) BaseCacheSeparateBodyBaseCache)CacheControllerctj}|tjtjzz}t tdr|tjz}t tdr|tjz} tj|n#ttf$rYnwxYwtj |||} tj |dS#tj |xYw)N O_NOFOLLOWO_BINARYwb) osO_WRONLYO_CREATO_EXCLhasattrr r removeIOErrorOSErroropenfdopenclose)filenamefmodeflagsfds _/opt/cloudlinux/venv/lib/python3.11/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py_secure_open_writers KE  RZ") ##Er<   r:   ( W       5% ( (ByT"""   s2BBB5C C!c`eZdZdZ ddZedZdZd Zdd Z d e fd Z d Z dS)_FileCacheMixinz2Shared implementation for both FileCache variants.FNc||td ddlm}ddlm}|r|}n1||}n,#t $rt d} t | wxYw||_||_||_ ||_ ||_ dS)Nz/Cannot use use_dir_lock and lock_class togetherr)LockFile) MkdirLockFilez NOTE: In order to use the FileCache you must have lockfile installed. You can install it via pip: pip install lockfile ) ValueErrorlockfiler"lockfile.mkdirlockfiler# ImportErrorr directoryforeverfilemodedirmode lock_class) selfr(r)r*r+ use_dir_lockr,r"r#notices r__init__z_FileCacheMixin.__init__?s  # (>NOO O & ) ) ) ) ) ) < < < < < < &* #%  & & &Ff%% % &"#    $s +)Acrtj|SN)hashlibsha224encode hexdigest)xs rr5z_FileCacheMixin.encodefs&~ahhjj))33555c||}t|dd|gz}tjj|jg|RS)N)r5listr pathjoinr()r-namehashedpartss r_fnz_FileCacheMixin._fnjsMT""VBQBZ  F8+w|DN3U3333r8c||} t|d5}|cdddS#1swxYwYdS#t$rYdSwxYw)Nrb)rArreadFileNotFoundError)r-keyr>fhs rgetz_FileCacheMixin.getqsxx}} dD!! !Rwwyy ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !!   44 s3AA AA  AA A A#"A#c\||}|||dSr2rA_write)r-rFvalueexpiresr>s rsetz_FileCacheMixin.setzs+xx}} D%     r8datac tjtj||jn#t t f$rYnwxYw||5}t|j|j 5}| |dddn #1swxYwYddddS#1swxYwYdS)z: Safely write the data to the given path. N) r makedirsr<dirnamer+rrr,rr*write)r-r<rOlockrGs rrKz_FileCacheMixin._write~s;   K--t| < < < <!    D __T " " d#DIt}==                                  sE7:A A&B;B# B;#B' 'B;*B' +B;;B?B?c|||z}|js( tj|dS#t$rYdSwxYwdSr2)rAr)r rrE)r-rFsuffixr>s r_deletez_FileCacheMixin._deletesbxx}}v%|   $$      s7 AA)Frr NNr2) __name__ __module__ __qualname____doc__r0 staticmethodr5rArHrNbytesrKrWr8rrr<s<< %%%%%%%%N66\6444!!!!     r8rceZdZdZdZdS) FileCachezc Traditional FileCache: body is stored in memory, so not suitable for large downloads. c2||ddS)NrWr-rFs rdeletezFileCache.deletes S"r8N)rXrYrZr[rer^r8rr`r`s- r8r`c$eZdZdZdZdZdZdS)SeparateBodyFileCachezh Memory-efficient FileCache: body is stored in a separate file, reducing peak memory usage. cv||dz} t|dS#t$rYdSwxYw)N.bodyrC)rArrE)r-rFr>s rget_bodyzSeparateBodyFileCache.get_bodysMxx}}w& d## #    44 s * 88cb||dz}|||dS)NrirJ)r-rFbodyr>s rset_bodyzSeparateBodyFileCache.set_bodys0xx}}w& D$r8c^||d||ddS)Nrbrircrds rrezSeparateBodyFileCache.deletes0 S" S'"""""r8N)rXrYrZr[rjrmrer^r8rrgrgsK    #####r8rgcTtj|}||S)z\Return the file cache path based on the URL. This does not ensure the file exists! )r cache_urlrA)url filecacherFs rurl_to_file_pathrss&  #C ( (C ==  r8)r3r textwraprcacherr controllerrrE NameErrorrrrrr`rgrsr^r8rrxsB  44444444((((((++++ '*+ &&&RWWWWWWWWt#####O-B###,s ! --