ó
    Ñ]jÇ  ã                  óJ  • % S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	  SSK
JrJrJrJr  \(       a  SSKJr  SSKJr  \R&                  " \5      rS	\S
'   \ " S S\5      5       r\ " S S\5      5       r " S S5      r " S S5      r " S S\5      r " S S\5      r/ SQrg)zMCache Protocol and built-in implementations for Python interpreter discovery.é    )ÚannotationsN)ÚcontextmanagerÚsuppress)Úsha256)ÚTYPE_CHECKINGÚFinalÚProtocolÚruntime_checkable)Ú	Generator)ÚPathzFinal[logging.Logger]Ú_LOGGERc                  óT   • \ rS rSrSrS
S jrSS jrSS jrSS jr\	SS j5       r
Srg	)ÚContentStoreé   z/A store for reading and writing cached content.c                ó   • g)z)Return whether the cached content exists.N© ©Úselfs    ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/python_discovery/_cache.pyÚexistsÚContentStore.exists   ó   € àó    c                ó   • g)z?Read the cached content, or ``None`` if unavailable or corrupt.Nr   r   s    r   ÚreadÚContentStore.read   r   r   c                ó   • g)zQ
Persist *content* to the store.

:param content: interpreter metadata to cache.
Nr   ©r   Úcontents     r   ÚwriteÚContentStore.write   ó   € ð 	r   c                ó   • g)zDelete the cached content.Nr   r   s    r   ÚremoveÚContentStore.remove&   r   r   c                ó   • g)z>Context manager that acquires an exclusive lock on this store.Nr   r   s    r   ÚlockedÚContentStore.locked*   s   € ð 	r   r   N©ÚreturnÚbool©r*   zdict | None©r   Údictr*   ÚNone©r*   r/   ©r*   zGenerator[None]©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r    r$   r   r'   Ú__static_attributes__r   r   r   r   r      s-   † á9ôôôôð óó ór   r   c                  ó,   • \ rS rSrSrSS jrSS jrSrg)	ÚPyInfoCacheé0   z3Cache interface for Python interpreter information.c                ó   • g)úm
Return the content store for the interpreter at *path*.

:param path: absolute path to a Python executable.
Nr   ©r   Úpaths     r   Úpy_infoÚPyInfoCache.py_info4   r"   r   c                ó   • g)ú*Remove all cached interpreter information.Nr   r   s    r   Úpy_info_clearÚPyInfoCache.py_info_clear<   r   r   r   N)r?   r   r*   r   r0   ©r3   r4   r5   r6   r7   r@   rD   r8   r   r   r   r:   r:   0   s   † á=ô÷r   r:   c                  ór   • \ rS rSrSrSS jr\SS j5       rSS jrSS jr	SS jr
SS jr\SS	 j5       rS
rg)ÚDiskContentStoreéA   z0JSON file-based content store with file locking.c                ó   • Xl         X l        g ©N©Ú_folderÚ_key)r   ÚfolderÚkeys      r   Ú__init__ÚDiskContentStore.__init__D   s   € ØŒØ�	r   c                ó:   • U R                   U R                   S3-  $ )Nú.jsonrL   r   s    r   Ú_fileÚDiskContentStore._fileH   s   € à�|‰| §¡ ¨5Ð1Ñ1Ð1r   c                ó6   • U R                   R                  5       $ rK   )rU   r   r   s    r   r   ÚDiskContentStore.existsL   s   € Ø�z‰z× Ñ Ó"Ð"r   c                ó¦  • Su  p [         R                  " U R                  R                  SS95      n[        R                  SU R                  5        U$ ! [         a    Sn O.[         a"    [        R                  SU R                  SS9   Of = fU(       a:  [        [        5         U R                  5         S S S 5        g ! , (       d  f       g = fg )N©NFúutf-8©Úencodingzgot python info from %sTzfailed to read %s)Úexc_info)
ÚjsonÚloadsrU   Ú	read_textr   ÚdebugÚ
ValueErrorÚOSErrorr   r$   )r   ÚdataÚ
bad_formats      r   r   ÚDiskContentStore.readO   s¬   € Ø&Ñˆð	Ü—:’:˜dŸj™j×2Ñ2¸GÐ2ÐDÓEˆDô �M‰MÐ3°T·Z±ZÔ@ØˆKøô ó 	ØŠJÜó 	JÜ�M‰MÐ-¨t¯z©zÀDˆMÓIð	Júö
 Üœ'Õ"Ø—‘”÷ #à÷ #Ô"àúˆts#   †-A ÁBÁ#(BÂBÂ'CÃ
Cc                óÔ   • U R                   R                  SSS9  U R                  R                  [        R
                  " USSS9SS9  [        R                  SU R                  5        g )NT©ÚparentsÚexist_oké   )Ú	sort_keysÚindentr[   r\   zwrote python info at %s)rM   ÚmkdirrU   Ú
write_textr_   Údumpsr   rb   r   s     r   r    ÚDiskContentStore.write_   sQ   € Ø�‰×Ñ 4°$ÐÑ7Ø�
‰
×ÑœdŸjšj¨¸DÈÑKÐV]ÐÑ^Ü�‰Ð/°·±Õ<r   c                óÊ   • [        [        5         U R                  R                  5         S S S 5        [        R                  SU R                  5        g ! , (       d  f       N/= f)Nzremoved python info at %s)r   rd   rU   Úunlinkr   rb   r   s    r   r$   ÚDiskContentStore.removed   s;   € Ü”gÕØ�J‰J×ÑÔ÷ ä�‰Ð1°4·:±:Õ>÷ Õús   �AÁ
A"c              #  óâ   #   • SSK Jn  U R                  U R                   S3-  nUR                  R                  SSS9  U" [        U5      5         S v •  S S S 5        g ! , (       d  f       g = f7f)Nr   )ÚFileLockz.lockTri   )Úfilelockrw   rM   rN   Úparentro   Ústr)r   rw   Ú	lock_paths      r   r'   ÚDiskContentStore.lockedi   sT   é € å%à—L‘L d§i¡i [°Ð#6Ñ6ˆ	Ø×Ñ×Ñ t°dÐÑ;Ù”c˜)“nÕ%Û÷ &×%Ö%üs   ‚AA/ÁAÁ	A/Á
A,Á(A/rL   N)rO   r   rP   rz   r*   r/   ©r*   r   r)   r,   r-   r0   r1   )r3   r4   r5   r6   r7   rQ   ÚpropertyrU   r   r   r    r$   r   r'   r8   r   r   r   rH   rH   A   sF   † Ù:ôð ó2ó ð2ô#ôô =ô
?ð
 óó ór   rH   c                  óJ   • \ rS rSrSrS	S jr\S
S j5       rSS jrSS jr	Sr
g)Ú	DiskCacheés   z‹
File-system based Python interpreter info cache (``<root>/py_info/4/<sha256>.json``).

:param root: root directory for the on-disk cache.
c                ó   • Xl         g rK   ©Ú_root)r   Úroots     r   rQ   ÚDiskCache.__init__z   s   € Ø�
r   c                ó&   • U R                   S-  S-  $ )Nr@   Ú4rƒ   r   s    r   Ú_py_info_dirÚDiskCache._py_info_dir}   s   € à�z‰z˜IÑ%¨Ñ+Ð+r   c                ó�   • [        [        U5      R                  S5      5      R                  5       n[	        U R
                  U5      $ )r=   r[   )r   rz   ÚencodeÚ	hexdigestrH   r‰   )r   r?   rP   s      r   r@   ÚDiskCache.py_info�   s9   € ô ”S˜“Y×%Ñ% gÓ.Ó/×9Ñ9Ó;ˆÜ × 1Ñ 1°3Ó7Ð7r   c                ó  • U R                   nUR                  5       (       aR  UR                  5        H=  nUR                  S:X  d  M  [	        [
        5         UR                  5         SSS5        M?     gg! , (       d  f       MR  = f)rC   rT   N)r‰   r   ÚiterdirÚsuffixr   rd   rt   )r   rO   Úentrys      r   rD   ÚDiskCache.py_info_clearŠ   s\   € à×"Ñ"ˆØ�=‰=�?‰?ØŸ™Ö)�Ø—<‘< 7Õ*Ü!¤'Õ*ØŸ™œ÷ +Ñ*ò *ð ÷ +Ö*ús   ÁA5Á5
B	rƒ   N)r…   r   r*   r/   r}   )r?   r   r*   rH   r0   )r3   r4   r5   r6   r7   rQ   r~   r‰   r@   rD   r8   r   r   r   r€   r€   s   s*   † ñôð ó,ó ð,ô8÷'r   r€   c                  óT   • \ rS rSrSrS
S jrSS jrSS jrSS jr\	SS j5       r
Srg	)ÚNoOpContentStoreé”   zDContent store that does nothing -- implements ContentStore protocol.c                ó   • grZ   r   r   s    r   r   ÚNoOpContentStore.exists—   s   € Ør   c                ó   • g rK   r   r   s    r   r   ÚNoOpContentStore.readš   s   € Ør   c                ó   • g rK   r   r   s     r   r    ÚNoOpContentStore.write�   ó   € Ør   c                ó   • g rK   r   r   s    r   r$   ÚNoOpContentStore.remove    r�   r   c              #  ó   #   • S v •  g 7frK   r   r   s    r   r'   ÚNoOpContentStore.locked£   s   é € äùs   ‚r   Nr)   r,   r-   r0   r1   r2   r   r   r   r•   r•   ”   s-   † ÙNôôôôð óó ór   r•   c                  ó,   • \ rS rSrSrSS jrSS jrSrg)	Ú	NoOpCacheé¨   z;Cache that does nothing -- implements PyInfoCache protocol.c                ó   • [        5       $ rK   )r•   r>   s     r   r@   ÚNoOpCache.py_info«   s   € ÜÓ!Ð!r   c                ó   • g rK   r   r   s    r   rD   ÚNoOpCache.py_info_clear®   r�   r   r   N)r?   r   r*   r•   r0   rF   r   r   r   r£   r£   ¨   s   † ÙEô"÷r   r£   )r   r€   rH   r£   r•   r:   )r7   Ú
__future__r   r_   ÚloggingÚ
contextlibr   r   Úhashlibr   Útypingr   r   r	   r
   Úcollections.abcr   Úpathlibr   Ú	getLoggerr3   r   Ú__annotations__r   r:   rH   r€   r•   r£   Ú__all__r   r   r   Ú<module>r³      s§   ðÚ Så "ã Û ß /Ý ß DÓ DæÝ)Ýà!(×!2Ò!2°8Ó!<€Ð	Ó <ð ô�8ó ó ðð: ô�(ó ó ð÷ /ñ /÷d'ñ 'ôB�|ô ô(�ô ò�r   