Ë
    ãš¾j$(  ã                  óü  — U d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
 d dlmZ dZded<    e ed	d
«      «       ed«      hz
  Zded<   dZded<   d;d„Zd<d„Zej,                  dk(  �rod dlZd dlmZ  ej2                  dd¬«      Zded<   ej6                  gej8                  _        ej<                  ej8                  _        ej@                  ej<                  ej@                  gejB                  _        ej6                  ejB                  _        ej6                   ejD                  ejF                  «       ejD                  ejF                  «       ejD                  ejF                  «       ejD                  ejF                  «      gejH                  _        ej<                  ejH                  _        dZ%ded<   dZ&ded<   dZ'ded<   dZ(d ed!<   d=d"„Z)d>d#„Z*nšd=d$„Z)ej,                  d%v rd&Z+ded'<   d?d(„Z, e,«       Z-ded)<   d>d*„Z*nlej,                  d+k(  rYd dlZd dl.Z. ej^                  dd¬,«      Z0d-ed.<   d/Z1ded0<   d1Z2ded2<   d/Z3ded3<   d4Z4d5ed6<    e.jj                  e4«      Z6ded7<   d>d8„Z*nd>d9„Z*g d:¢Z7y)@é    )ÚannotationsN)ÚEPERMÚESRCH)ÚPath)ÚFinaléý   z
Final[int]Ú_HOST_NAME_LIMITé!   é   ú?zFinal[frozenset[int]]Ú_HOST_NAME_VERBATIMé   Ú_HOST_NAME_DIGEST_LENc                 óL  — dj                  d„ t        j                  «       j                  dd«      D «       «      } t	        | «      t
        kD  rSt
        t        z
  dz
  }| d| › dt        j                  | |d j                  «       «      j                  «       dt         › �} | xs dS )	aß  
    The hostname recorded alongside an owner, so a marker written on another machine is never probed here.

    Marker formats here hold the field to printable non-space ASCII, while ``socket.gethostname()`` reports whatever
    the kernel stores: a space, a newline that forges an extra marker line, or a byte no codec encodes, which Python
    hands back as a surrogate. A holder that publishes one raw writes a marker it cannot read back, and loses the lock
    to the first peer that ages it out as malformed. ``?`` is illegal in a hostname, so escaping it along with every
    out-of-grammar byte as ``?<hex>`` leaves a real name untouched and still keeps two hosts apart, which
    :func:`owner_is_stale` relies on to refuse to probe a foreign PID.

    An over-long name ends in a digest of the part cut to fit the limit. A bare cut gives every name that shares the
    kept prefix one identity, and :func:`owner_is_stale` would then probe a local PID for another host's holder.
    Ú c              3  óN   K  — | ]  }|t         v rt        |«      nd |d›�–— Œ y­w)r   Ú02xN)r   Úchr)Ú.0Úbytes     ú\/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/filelock/_identity.pyú	<genexpr>zhost_name.<locals>.<genexpr>!   s1   è ø€ ò àð Ô0Ñ0ŒˆDŒ	¸¸$¸s¸°nÓDñùs   ‚#%zutf-8Úsurrogateescapeé   Nú-r   )
ÚjoinÚsocketÚgethostnameÚencodeÚlenr	   r   ÚhashlibÚsha256Ú	hexdigest)ÚnameÚkeeps     r   Ú	host_namer&      s    € ð �7‰7ñ ä×&Ñ&Ó(×/Ñ/°Ð9JÓKôó €Dô ˆ4ƒyÔ#Ò#ÜÔ"7Ñ7¸!Ñ;ˆØ�u˜�+�˜a¤§¡¨t°D°E¨{×/AÑ/AÓ/CÓ D× NÑ NÓ PÐQgÔRgÐ hÐiÐjˆàŠ;�3Ðó    c                óh   — |t        «       k7  ryt        | «      sy|€yt        | «      }|duxr ||k7  S )a‚  
    Whether the recorded owner is provably gone, so reclaiming its marker cannot detach a live holder.

    Fail closed: return ``True`` only when this process can prove the exact recorded owner is dead. A marker from
    another host cannot be probed; a live PID whose start token still matches, or whose token cannot be read, is the
    holder or is indistinguishable from it; a live PID whose start token differs is a recycled PID, so the process that
    wrote the marker is gone. PostgreSQL, Qt ``QLockFile`` and Mercurial all break a stale lock only on proof of death
    and treat an unreadable or foreign owner as still holding.
    FTN)r&   Úprocess_aliveÚprocess_start_token)ÚpidÚhostnameÚstart_tokenÚcurrents       r   Úowner_is_staler/   ,   sD   € ð ”9“;ÒØÜ˜ÔØØÐØÜ! #Ó&€GØ˜$ÐÒ9 7¨kÑ#9Ð9r'   Úwin32)ÚwintypesÚkernel32T)Úuse_last_errorzFinal[ctypes.WinDLL]Ú	_KERNEL32i   Ú_WIN_SYNCHRONIZEi   Ú&_WIN_PROCESS_QUERY_LIMITED_INFORMATIONéW   Ú_WIN_ERROR_INVALID_PARAMETERFzFinal[bool]Ú_WIN_INHERIT_HANDLEc                ó¦   — t         j                  t        t        | «      }|rt         j	                  |«       yt        j                  «       t        k7  S )zSWhether a process with this PID exists, treating an access denial as proof it does.T)r4   ÚOpenProcessr5   r9   ÚCloseHandleÚctypesÚget_last_errorr8   )r+   Úhandles     r   r)   r)   W   sA   € ä×&Ñ&Ô'7Ô9LÈcÓRˆÙÜ×!Ñ! &Ô)ØÜ×$Ñ$Ó&Ô*FÑFÐFr'   c           	     ó  — t         j                  t        t        | «      }|syd„ t	        d«      D «       \  }}}}	 t         j                  |t        j                  |«      t        j                  |«      t        j                  |«      t        j                  |«      «      s	 t         j                  |«       y	 t         j                  |«       |j                  dz  |j                  z  S # t         j                  |«       w xY w)zXThe process creation FILETIME as a 100ns tick count, or ``None`` when it cannot be read.Nc              3  óD   K  — | ]  }t        j                  «       –— Œ y ­w)N)r1   ÚFILETIME)r   Ú_s     r   r   z&process_start_token.<locals>.<genexpr>d   s   è ø€ Ò6]Èq´x×7HÑ7H×7JÑ6]ùs   ‚ é   é    )r4   r;   r6   r9   ÚrangeÚGetProcessTimesr=   Úbyrefr<   ÚdwHighDateTimeÚdwLowDateTime)r+   r?   ÚcreationÚ	exit_timeÚkernel_timeÚ	user_times         r   r*   r*   _   sÕ   € ä×&Ñ&Ô'MÔObÐdgÓhˆÙØÙ6]ÔTYÐZ[ÓT\Ô6]Ñ3ˆ�)˜[¨)ð
	*Ü×,Ñ,ØÜ—‘˜XÓ&Ü—‘˜YÓ'Ü—‘˜[Ó)Ü—‘˜YÓ'ôð ä×!Ñ! &Õ)ðô ×!Ñ! &Ô)Ø×'Ñ'¨2Ñ-°×1GÑ1GÑGÐGøô ×!Ñ! &Õ)ús   »A%C) Ã)D c                ó¶   — 	 t        j                  | d«       y# t        $ r6}|j                  t        k(  rY d}~y|j                  t
        k(  rY d}~y‚ d}~ww xY w)z_Whether a process with this PID exists, treating an access denial (``EPERM``) as proof it does.r   NFT)ÚosÚkillÚOSErrorÚerrnor   r   )r+   Úerrors     r   r)   r)   t   sL   € ð	Ü�G‰G�C˜ŒOð øô ò 	Ø�{‰{œeÒ#ÜØ�{‰{œeÒ#ÜØûð	ús   ‚ ™	A¢AºAÁAÁA>   ÚlinuxÚandroidé   Ú_STARTTIME_INDEXc                 ó¸   — 	 t        d«      j                  d¬«      } t        | j                  «       j	                  dd«      d«      S # t
        t        f$ r Y yw xY w)Nz/proc/sys/kernel/random/boot_idÚascii)Úencodingr   r   é   r   )r   Ú	read_textÚintÚstripÚreplacerR   Ú
ValueError)Úboot_ids    r   Ú_read_boot_idrc   ‡   sX   € ðÜÐ@ÓA×KÑKÐU\ÐKÓ]�Ü˜7Ÿ=™=›?×2Ñ2°3¸Ó;¸RÓ@Ð@øÜœZÐ(ò Ùðús   ‚AA ÁAÁAÚ_BOOT_IDc                ó(  — 	 t        d| › d�«      j                  «       }||j                  d«      dz   d j	                  «       }t        |«      t        k  ry	 t        |t           «      }t        dz  |z  S # t        $ r Y yw xY w# t        $ r Y yw xY w)zeThe ``/proc/<pid>/stat`` ``starttime`` folded with the boot id, or ``None`` when the process is gone.z/proc/z/statNó   )r   é@   )
r   Ú
read_bytesrR   ÚrfindÚsplitr    rX   r^   ra   rd   )r+   ÚdataÚfieldsÚ	starttimes       r   r*   r*   •   s¦   € ðÜ˜f S E¨Ð/Ó0×;Ñ;Ó=�ð ˜$Ÿ*™* TÓ*¨QÑ.Ð0Ð1×7Ñ7Ó9ˆFÜ�6‹{Ô.Ò.ØðÜ Ô'7Ñ 8Ó9�	ô  ‘N iÑ/Ð/øô ò Ùðûô ò Ùðús#   ‚A6 ÁB Á6	BÂBÂ	BÂBÚdarwin)Ú	use_errnozFinal[ctypes.CDLL]Ú_LIBCr   Ú	_CTL_KERNé   Ú
_KERN_PROCÚ_KERN_PROC_PIDz<qiz
Final[str]Ú_TIMEVAL_AT_ZEROÚ_TIMEVAL_SIZEc                ó  — t        j                  dz  t        t        t        | «      }t        j
                  d«      }t        j                  |ddt        j                  |«      dd«      dk7  ryt        j                  |j                  z  «       }t        j                  |d|t        j                  |«      dd«      dk7  s|j                  t        k  ryt        j                  t        |j                  d«      \  }}|dz  |z   S )zcThe process start time in microseconds from ``sysctl(KERN_PROC_PID)``, or ``None`` when it is gone.rD   r   Ni@B )r=   Úc_intrq   rs   rt   Úc_size_trp   ÚsysctlrH   Úc_charÚvaluerv   ÚstructÚunpack_fromru   Úraw)r+   ÚmibÚlengthÚbufferÚsecondsÚmicrosecondss         r   r*   r*   ²   sÌ   € ä—<‘< !Ñ#¤Y´
¼NÈCÓPˆCÜ—_‘_ QÓ'ˆFô �|‰|˜C  D¬&¯,©,°vÓ*>ÀÀaÓHÈAÒMØÜ—m‘m f§l¡lÑ2Ó5ˆFÜ�|‰|˜C  F¬F¯L©L¸Ó,@À$ÈÓJÈaÒOÐSY×S_ÑS_ÔboÒSoØÜ$*×$6Ñ$6Ô7GÈÏÉÐUVÓ$WÑ!ˆG�\Ø˜YÑ&¨Ñ5Ð5r'   c                 ó   — ~ y)z_No proven start-time source, so the owner carries no token and liveness rests on the PID alone.N© )r+   s    r   r*   r*   Â   s   € àØr'   )r&   r/   r)   r*   )ÚreturnÚstr)r+   r^   r,   rˆ   r-   ú
int | Noner‡   Úbool)r+   r^   r‡   rŠ   )r+   r^   r‡   r‰   )r‡   r^   )8Ú
__future__r   r!   rP   r   ÚsysrS   r   r   Úpathlibr   Útypingr   r	   Ú__annotations__Ú	frozensetrF   Úordr   r   r&   r/   Úplatformr=   r1   ÚWinDLLr4   ÚHANDLEr<   ÚargtypesÚBOOLÚrestypeÚDWORDr;   ÚPOINTERrB   rG   r5   r6   r8   r9   r)   r*   rX   rc   rd   r}   ÚCDLLrp   rq   rs   rt   ru   Úcalcsizerv   Ú__all__r†   r'   r   ú<module>r�      sS  ðÞ "ã Û 	Û Û 
ß Ý Ý ð  #Ð �*Ó "á-6±u¸TÀ4Ó7HÓ-IÉSÐQTËXÈJÑ-VÐ Ð*Ó Và$%Ð �zÓ %óó2:ð( ‡<�<�7ÓÛÝà&3 f§m¡m°JÈtÔ&T€IÐ#ÓTØ&.§o¡oÐ%6€I×ÑÔ"Ø$,§M¡M€I×ÑÔ!Ø&.§n¡n°h·m±mÀXÇ^Á^Ð%T€I×ÑÔ"Ø$,§O¡O€I×ÑÔ!à�‰Øˆ�‰�x×(Ñ(Ó)Øˆ�‰�x×(Ñ(Ó)Øˆ�‰�x×(Ñ(Ó)Øˆ�‰�x×(Ñ(Ó)ð*€I×ÑÔ&ð )1¯©€I×ÑÔ%à#+Ð�jÓ+Ø9?Ð*¨JÓ?Ø/1Ð  *Ó1Ø',Ð˜Ó,óGôHó*
ð ‡|�|Ð+Ñ+ð
 (*Ð˜*Ó)ó
	ñ  -›ˆ�*Ó.ô	0ð  
�‰˜Ò	!ÛÛà$/ F§K¡K°ÀÔ$EˆÐ!ÓEØ !ˆ	�:Ó!Ø!#ˆ
�JÓ#Ø%&ˆ˜
Ó&ð (-Ð˜*Ó,Ø$3 F§O¡OÐ4DÓ$Eˆ�zÓEô	6ó 	ò�r'   