
    *pj                        % S SK Jr  S SKrS SKrS SKJr  S SKJrJrJ	r	  SSK
JrJr  SSKJrJr  SSKJr  S	rS
\S'   SrS\S'   \S   r " S S\	5      r " S S\5      rSS jrSS jrSS jr/ SQrg)    )annotationsN)suppress)FinalLiteral
NamedTuple   )	host_nameprocess_start_token)SoftFileLock_read_lock_file)	write_allz
filelock/2z
Final[str]	_PROTOCOLiz
Final[int]_MAX_PID)leaseunknownc                  b    \ rS rSr% SrS\S'   S\S'   S\S'   S	rS
\S'   S	rS\S'   S	rS\S'   Sr	g	)OwnerRecord   z+The owner published in a protocol 2 marker.intpidstrhostname	OwnerModemodeN
str | Nonetokenzfloat | Nonelease_duration
int | Nonestart )
__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   __static_attributes__r        L/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/filelock/_marker.pyr   r      s2    5	HM
OE:#'NL'E:r(   r   c                      \ rS rSr% SrS\S'   \SS j5       r\SS j5       r\SS j5       r	SS jr
SS	 jrSS
 jrSS jrSrg)MarkerSoftFileLock#   zAAn existence lock whose marker carries a protocol 2 owner record.r   _owner_modec                "    U R                  5       $ )z
The owner named by the marker on disk.

:returns: the published record, or ``None`` when no marker exists or its record is malformed or protocol 1

)_read_ownerselfs    r)   ownerMarkerSoftFileLock.owner)   s     !!r(   c                D    U R                  5       =nc  S$ UR                  $ )z
The PID of the process holding this lock, read from the marker.

:returns: the PID, or ``None`` when no marker exists or its record is unreadable

N)r/   r   r1   r2   s     r)   r   MarkerSoftFileLock.pid3   s&     "&!1!1!33<tK%))Kr(   c                    U R                  5       nUSL=(       a@    UR                  [        R                  " 5       :H  =(       a    UR                  [        5       :H  $ )z{
Whether the marker on disk names this process.

:returns: ``True`` when the marker's PID and hostname match this process

N)r/   r   osgetpidr   r	   r5   s     r)   is_lock_held_by_us%MarkerSoftFileLock.is_lock_held_by_us=   sC       "D _UYY"))+%=_%..T]T_B__r(   c                $    U R                  5         g)a  
Remove the marker whoever holds it, so a later contender can acquire.

Forced breaking voids mutual exclusion: the previous holder keeps running and keeps using whatever the lock
protects. Reserve it for an operator clearing a marker whose holder is known to be gone.
N)
break_lockr0   s    r)   force_breakMarkerSoftFileLock.force_breakH   s     	r(   c                    [        [        [        5         [        [	        U R
                  5      S   5      sS S S 5        $ ! , (       d  f       g = f)Nr   )r   OSError
ValueErrorparse_markerr   	lock_filer0   s    r)   r/   MarkerSoftFileLock._read_ownerQ   s1    gz* ? BC +**s   !A  
Ac                J    [        U[        U R                  5       5      5        g )N)r   encode_marker_published_record)r1   fds     r)   _write_lock_info#MarkerSoftFileLock._write_lock_infoV   s    "mD$:$:$<=>r(   c           	         [        [        R                  " 5       [        5       U R                  [        [        R                  " 5       5      S9$ )N)r   r   r   r   )r   r8   r9   r	   r-   r
   r0   s    r)   rH   $MarkerSoftFileLock._published_recordY   s4    		[!!%biik2	
 	
r(   r    N)returnOwnerRecord | None)rN   r   )rN   bool)rN   None)rI   r   rN   rQ   )rN   r   )r!   r"   r#   r$   r%   r&   propertyr2   r   r:   r>   r/   rJ   rH   r'   r    r(   r)   r+   r+   #   s_    K " " L L ` `
?
r(   r+   c                   [         SU R                   3SU R                   3SU R                   3/nU R                  b  UR                  SU R                   35        U R                  b  UR                  SU R                  < 35        U R                  b  UR                  SU R                   35        SR                  S U 5       5      R                  5       $ )	z>Render an owner record as the bytes a protocol 2 marker holds.zpid=zhost=zmode=ztoken=z	duration=zstart= c              3  *   #    U  H	  o S 3v   M     g7f)
Nr    ).0lines     r)   	<genexpr> encode_marker.<locals>.<genexpr>k   s     154V2;5s   )
r   r   r   r   r   appendr   r   joinencode)recordliness     r)   rG   rG   b   s    $vzzl+uV__4E-F%PVP[P[}H]^E||vfll^,-(y!6!6 9:;||vfll^,-77151188::r(   c                    U (       a2  U R                  5       R                  5       =n(       a  US   [        :w  a  g0 nUSS  H$  nUR                  S5      u  pEnU(       d    gXbU'   M&     [	        U5      $ )zcReturn the owner a protocol 2 marker names, or ``None`` when the record is malformed or protocol 1.r   Nr   =)strip
splitlinesr   	partition_build_record)contentr_   fieldsrX   key	separatorvalues          r)   rC   rC   n   so    GMMO$>$>$@@5@U1XQZEZFab	 $s 3s	 
   r(   c           	        U R                  S5      =nc  g US:X  a  SOSnU R                  S5      nU(       a  SU ;  a  g  [        U S   5      nSU ;   a  [        U S   5      OS nSU ;   a  [        U S   5      OS nSUs=::  a  [        ::  d   g   g U R                  S	5      nUS:X  a(  Ub$  Ub!  [
        R                  " U5      (       a  US
:  d  g [        XCX'XVS9$ ! [         a     g f = f)Nr   r   r   hostr   durationr   r   r   r   )r   r   r   r   r   r   )getr   floatrB   r   mathisfiniter   )rg   	publishedr   r   r   rm   r   r   s           r)   re   re   {   s    
 ZZ''	0!*g!5g9Dzz&!HuF*&- 0:f0D5
+,$(/6(9F7O$t x  JJwE wEMX-=dmmT\F]F]bjmnbn3Zbpp  s    :C 
C&%C&)r+   r   r   rG   rC   )r^   r   rN   bytes)rf   r   rN   rO   )rg   zdict[str, str]rN   rO   )
__future__r   rp   r8   
contextlibr   typingr   r   r   	_identityr	   r
   _softr   r   _utilr   r   r&   r   r   r   r+   rG   rC   re   __all__r    r(   r)   <module>r{      ss    "  	  - - 5 0 
 %	: $ *   &'	* <
 <
~	;
!q8r(   