ZL i*dZddlZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZej0d k\rdd l mZndd lmZGd deZde fdZeZdede fdZe GddZy)z;Caching of formatted files with feature-based invalidation.N)Iterable) dataclassfield)Path) NamedTuple)user_cache_dir)version)Mode)err) )Selfc,eZdZUeed<eed<eed<y)FileDatast_mtimest_sizehashN)__name__ __module__ __qualname__float__annotations__intstrQ/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/black/cache.pyrrsO L Irrreturnctd}ttjj d|}|t z }|S)a[Get the cache directory used by black. Users can customize this directory on all systems using `BLACK_CACHE_DIR` environment variable. By default, the cache directory is the user cache directory under the black application. This result is immediately set to a constant `black.cache.CACHE_DIR` as to avoid repeated calls. blackBLACK_CACHE_DIR)rrosenvironget __version__)default_cache_dir cache_dirs r get_cache_dirr(s:'w/RZZ^^$57HIJIK'I rmodec8td|jdz S)Nzcache.z.pickle) CACHE_DIR get_cache_key)r)s rget_cache_filer-3s  2 2 45W= ==rceZdZUeed<eed<eeZee e fed<e dede fdZ edede fdZedede fd Zd edefd Zd eedeeeeeffd Zd eeddfdZy)Cacher) cache_file)default_factory file_datarc t|} |j}|s |||S|j d5} t j |}|jDcic]\}}|t|} }} ddd||| S#t$r$}td|d||||cYd}~Sd}~wwxYwcc}}w#t jttf$r|||cYcdddSwxYw#1swYxYw)zRead the cache if it exists and is well-formed. If it is not well-formed, the call to write later should resolve the issue. zUnable to read cache file z due to Nrb) r-existsOSErrorr openpickleloaditemsrUnpicklingError ValueError IndexError) clsr)r0r5efobjdatakvr2s rreadz Cache.read=s $D)  )&&(F tZ( ( __T " -d -:@++d:K9=FAQ! _F F -4Y// ) ,ZLD EtZ( ( )G**J C -4,,  - - -  - -sWB C8(C#B<6C B9B4.B94B9<C'C5)C84C55C88Dpathch|j}tj|jS)zReturn hash digest for path.) read_byteshashlibsha256 hexdigest)rErAs r hash_digestzCache.hash_digestWs( ~~d#--//rc|j}tj|}t|j|j |S)zReturn file data for path.)statr/rKrrr)rErMrs r get_file_datazCache.get_file_data^s6yy{  & t||T::rsourcecB|j}|jjt|}|y|j }|j |j k7ry|j |j k7r%tj|}||jk7ryy)z7Check if source has changed compared to cached version.TF) resolver2r$rrMrrr/rKr)selfrOres_srcoldstnew_hashs r is_changedzCache.is_changedfs~.."nn  W. ; \\^ :: $ ;;#,, &((1H388#rsourcesct}t}|D]6}|j|r|j|&|j|8||fS)zSplit an iterable of paths in `sources` into two sets. The first contains paths of files that modified on disk or are not in the cache. The other contains paths to non-modified files. )setrWadd)rRrXchangeddonesrcs rfiltered_cachedzCache.filtered_cachedvsP !U% Cs# C    }rNc |jjdi|Dcic]/}t|jtj |1c} t jddtjt|jjd5}|jjDcic] \}}|g| }}}tj||ddddtj j"|jycc}wcc}}w#1swY?xYw#t$$rYywxYw) z6Update the cache file data and write a new cache file.T)parentsexist_okF)dirdelete)protocolNr)r2updaterrQr/rNr+mkdirtempfileNamedTemporaryFiler0parentr:r8dumpr"replacenamer6)rRrXr^frBrCrAs rwritez Cache.writes GNOs3;;=!5#6#6s#;;O   OOD4O 8,,../ 1*.)=)=)?;!%AAuuH;; D!a0 1 JJqvvt /P;  1 1   sB4D A D5"D)D#D)+2D5#D))D2.D55 EE)rrrr rrrdictr2rr classmethodrrD staticmethodrKrNboolrWrtuplerZr_rprrrr/r/7s J%*4%@ItCM"@000020$0300 ;D;X;;$ x~ %D 3t9@T:U Xd^rr/) __doc__rHr"r8sysricollections.abcr dataclassesrrpathlibrtypingr platformdirsr_black_versionr r% black.moder black.outputr version_infortyping_extensionsrr(r+r-r/rrrrsA $('1w&z t" O >>$> ^^ ^r