Ë
    ¾lÔh’  ã                   ó*  — d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ej0                  dk\  rddlmZ nddlmZ  G d„ de«      Zdefd„Z e«       Zdedefd„Ze	 G d„ d«      «       Zy)z;Caching of formatted files with feature-based invalidation.é    N)ÚIterable)Ú	dataclassÚfield)ÚPath)Ú
NamedTuple)Úuser_cache_dir)Úversion)ÚMode)Úerr)é   é   )ÚSelfc                   ó,   — e Zd ZU eed<   eed<   eed<   y)ÚFileDataÚst_mtimeÚst_sizeÚhashN)Ú__name__Ú
__module__Ú__qualname__ÚfloatÚ__annotations__ÚintÚstr© ó    ú`/home/josh/.local/share/pipx/venvs/python-lsp-server/lib/python3.12/site-packages/black/cache.pyr   r      s   … ØƒOØƒLØ
„Ir   r   Úreturnc                  ó€   — t        d«      } t        t        j                  j	                  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.
    ÚblackÚBLACK_CACHE_DIR)r   r   ÚosÚenvironÚgetÚ__version__)Údefault_cache_dirÚ	cache_dirs     r   Úget_cache_dirr(      s:   € ô ' wÓ/ÐÜ”R—Z‘Z—^‘^Ð$5Ð7HÓIÓJ€IØœKÑ'€IØÐr   Úmodec                 ó8   — t         d| j                  «       › d�z  S )Nzcache.z.pickle)Ú	CACHE_DIRÚget_cache_key)r)   s    r   Úget_cache_filer-   3   s    € Ü˜ × 2Ñ 2Ó 4Ð5°WÐ=Ñ=Ð=r   c                   óè   — e Zd ZU eed<   eed<    ee¬«      Zee	e
f   ed<   ededefd„«       Zedede	fd„«       Zedede
fd	„«       Zd
edefd„Zdee   deee   ee   f   fd„Zdee   ddfd„Zy)ÚCacher)   Ú
cache_file)Údefault_factoryÚ	file_datar   c           	      ó  — t        |«      }	 |j                  «       }|s	 | ||«      S |j	                  d«      5 }	 t        j                  |«      }|j                  «       D ��ci c]  \  }}|t        |Ž “Œ }	}}	 ddd«        | ||	«      S # t        $ r$}t        d|› d|› �«        | ||«      cY d}~S d}~ww xY wc c}}w # t
        j                  t        t        f$ r  | ||«      cY cddd«       S w xY w# 1 sw Y   ŒxY w)z•Read the cache if it exists and is well-formed.

        If it is not well-formed, the call to write later should
        resolve the issue.
        zUnable to read cache file z due to NÚrb)r-   ÚexistsÚOSErrorr   ÚopenÚpickleÚloadÚitemsr   ÚUnpicklingErrorÚ
ValueErrorÚ
IndexError)
Úclsr)   r0   r5   ÚeÚfobjÚdataÚkÚvr2   s
             r   Úreadz
Cache.read=   s  € ô $ DÓ)ˆ
ð	)Ø×&Ñ&Ó(ˆFñ
 Ù�t˜ZÓ(Ð(à�_‰_˜TÓ"ð 	- dð-Ü:@¿+¹+ÀdÓ:K�Ø9=¿¹»×F±°°A˜Q¤¨! ™_ÐF�	ÒF÷	-ñ �4˜ YÓ/Ð/øô ò 	)äÐ,¨Z¨L¸ÀÀÐDÔEÙ�t˜ZÓ(Õ(ûð	)üó GøÜ×*Ñ*¬J¼
ÐCò -Ù˜4 Ó,Ñ,÷	-ñ 	-ð-ú÷		-ð 	-úsW   �B ¹C8»(CÁ#B<Á6CÂ	B9ÂB4Â.B9Â4B9Â<CÃ'C5Ã)C8Ã4C5Ã5C8Ã8DÚpathc                 óh   — | j                  «       }t        j                  |«      j                  «       S )zReturn hash digest for path.)Ú
read_bytesÚhashlibÚsha256Ú	hexdigest)rE   rA   s     r   Úhash_digestzCache.hash_digestW   s(   € ð �‰Ó ˆÜ�~‰~˜dÓ#×-Ñ-Ó/Ð/r   c                 óŽ   — | j                  «       }t        j                  | «      }t        |j                  |j
                  |«      S )zReturn file data for path.)Ústatr/   rK   r   r   r   )rE   rM   r   s      r   Úget_file_datazCache.get_file_data^   s6   € ð �y‰y‹{ˆÜ× Ñ  Ó&ˆÜ˜Ÿ™ t§|¡|°TÓ:Ð:r   Úsourcec                 óB  — |j                  «       }| j                  j                  t        |«      «      }|€y|j	                  «       }|j
                  |j
                  k7  ry|j                  |j                  k7  r%t        j                  |«      }||j                  k7  ryy)z7Check if source has changed compared to cached version.TF)
Úresolver2   r$   r   rM   r   r   r/   rK   r   )ÚselfrO   Úres_srcÚoldÚstÚnew_hashs         r   Ú
is_changedzCache.is_changedf   s~   € à—.‘.Ó"ˆØ�n‰n× Ñ ¤ W£Ó.ˆØˆ;Øà�\‰\‹^ˆØ�:‰:˜Ÿ™Ò$ØØ�;‰;˜#Ÿ,™,Ò&Ü×(Ñ(¨Ó1ˆHØ˜3Ÿ8™8Ò#ØØr   Úsourcesc                 ó¨   — t        «       }t        «       }|D ]6  }| j                  |«      r|j                  |«       Œ&|j                  |«       Œ8 ||fS )zÑSplit 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.
        )ÚsetrW   Úadd)rR   rX   ÚchangedÚdoneÚsrcs        r   Úfiltered_cachedzCache.filtered_cachedv   sP   € ô !›UˆÜ›%ˆØò 	ˆCØ�‰˜sÔ#Ø—‘˜CÕ à—‘˜•ð		ð
 ˜ˆ}Ðr   Nc                 óˆ  —  | j                   j                  di |D �ci c]/  }t        |j                  «       «      t        j                  |«      “Œ1 c}¤Ž 	 t        j                  dd¬«       t        j                  t        | j                  j                  «      d¬«      5 }| j                   j                  «       D ��ci c]  \  }}|g |¢­“Œ }}}t        j                  ||d¬«       ddd«       t        j                   j"                  | j                  «       yc c}w c c}}w # 1 sw Y   Œ?xY w# t$        $ r Y yw xY w)	z6Update the cache file data and write a new cache file.T)ÚparentsÚexist_okF)ÚdirÚdeleteé   )ÚprotocolNr   )r2   Úupdater   rQ   r/   rN   r+   ÚmkdirÚtempfileÚNamedTemporaryFiler0   Úparentr:   r8   Údumpr"   ÚreplaceÚnamer6   )rR   rX   r^   ÚfrB   rC   rA   s          r   ÚwritezCache.write…   s  € àˆ�‰×Ññ 	
ØGNÖOÀŒs�3—;‘;“=Ó!¤5×#6Ñ#6°sÓ#;Ñ;ÒOò	
ð	Ü�O‰O D°4ˆOÔ8Ü×,Ñ,Ü˜Ÿ™×.Ñ.Ó/¸ôð 1àð *.¯©×)=Ñ)=Ó)?÷;Ù!%  A�A�u˜‘u‘Hð;�ñ ;ô —‘˜D !¨aÕ0÷1ô �J‰J�q—v‘v˜tŸ™Õ/ùò Pùó;÷	1ð 1ûô ò 	Ùð	úsB   �4DÁAD5 Â"D)Ã D#ÃD)Ã+2D5 Ä#D)Ä)D2Ä.D5 Ä5	EÅ E)r   r   r   r
   r   r   r   Údictr2   r   r   Úclassmethodr   rD   ÚstaticmethodrK   rN   ÚboolrW   r   ÚtuplerZ   r_   rp   r   r   r   r/   r/   7   sÜ   … à
ƒJØÓÙ%*¸4Ô%@€Iˆt�C˜�MÑ"Ó@àð0˜ð 0 ò 0ó ð0ð2 ð0˜$ð 0 3ò 0ó ð0ð ð;˜Dð ; Xò ;ó ð;ð ð ¨$ó ð  x°¡~ð ¸%ÀÀDÁ	È3ÈtÉ9Ð@TÑ:Uó ð˜X d™^ð °ô r   r/   ) Ú__doc__rH   r"   r8   Úsysri   Úcollections.abcr   Údataclassesr   r   Úpathlibr   Útypingr   Úplatformdirsr   Ú_black_versionr	   r%   Ú
black.moder
   Úblack.outputr   Úversion_infor   Útyping_extensionsr   r(   r+   r-   r/   r   r   r   ú<module>r‚      s“   ðÙ Aã Û 	Û Û 
Û Ý $ß (Ý Ý å 'å 1Ý Ý à×Ñ�wÒÞå&ôˆzô ð�tó ñ" ‹O€	ð>˜ð > $ó >ð ÷^ð ^ó ñ^r   