+
    VBi                         R t ^ RIt^ RIt^ RIt^ RIt^ RIHtHtHtH	t	H
t
 . ROt ! R R]4      t ! R R4      t ! R R4      tR	 R
 ltR# )zGProvides an object-oriented model for handling :pep:`376` RECORD files.N)IterableIteratorOptionalTuplecastHashRecordEntryInvalidRecordEntryc                   <   a a ] tR t^t oRtV 3R ltR tRtVtV ;t	# )r	   zPRaised when a RecordEntry is not valid, due to improper element values or count.c                \   < \         SV `  R P                  V4      4       W n        Wn        R# )z, N)super__init__joinissueselements)selfr   r   	__class__s   &&&6/usr/lib/python3.14/site-packages/installer/records.pyr   InvalidRecordEntry.__init__   s#    6*+     c                N    R P                  V P                  V P                  4      # )z.InvalidRecordEntry(elements={!r}, issues={!r}))formatr   r   r   s   &r   __repr__InvalidRecordEntry.__repr__   s"    ?FFMM4;;
 	
r   r   r   )
__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r   r	   r	      s     Z!

 
r   c                      a  ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltR tV 3R	 lR
 lt	]
V 3R lR l4       tRtV tR# )r   z/Represents the "hash" element of a RecordEntry.c                *   < V ^8  d   QhRS[ RS[ RR/# )   namevaluereturnNstr)r   r%   s   "r   __annotate__Hash.__annotate__"   s"     
 
S 
 
 
r   c                    Wn         W n        R# )zConstruct a ``Hash`` object.

Most consumers should use :py:meth:`Hash.parse` instead, since no
validation or parsing is performed by this constructor.

:param name: name of the hash function
:param value: hashed value
Nr)   r*   )r   r)   r*   s   &&&r   r   Hash.__init__"   s     	
r   c                    < V ^8  d   QhRS[ /# r(   r+   r,   )r   r%   s   "r   r.   r/   .   s     + + +r   c                8    V P                    R V P                   2# )=r1   r   s   &r   __str__Hash.__str__.   s    ))Adjj\**r   c                    < V ^8  d   QhRS[ /# r4   r,   )r   r%   s   "r   r.   r/   1   s     A A# Ar   c                @    R V P                   : RV P                  : R2# )z
Hash(name=z, value=)r1   r   s   &r   r   Hash.__repr__1   s    DII=a@@r   c                    \        V\        4      '       g   \        # V P                  VP                  8H  ;'       d    V P                  VP                  8H  # N)
isinstancer   NotImplementedr*   r)   r   others   &&r   __eq__Hash.__eq__4   s=    %&&!!zzU[[(DDTYY%**-DDr   c                &   < V ^8  d   QhRS[ RS[/# r(   datar+   bytesbool)r   r%   s   "r   r.   r/   9   s     # #U #t #r   c                    \         P                  ! V P                  V4      P                  4       p\        P
                  ! V4      P                  R4      P                  R4      pV P                  V8H  # )zValidate that ``data`` matches this instance.

:param data: Contents of the file.
:return: Whether ``data`` matches the hashed value.
asciir6   )	hashlibnewr)   digestbase64urlsafe_b64encodedecoderstripr*   )r   rG   rO   r*   s   &&  r   validateHash.validate9   sV     TYY-446((077@GGLzzU""r   c                $   < V ^8  d   QhRS[ RR/# )r(   hr+   r   r,   )r   r%   s   "r   r.   r/   D   s        c  f  r   c                :    VP                  R^4      w  r#V ! W#4      # )a  Build a Hash object, from a "name=value" string.

This accepts a string of the format for the second element in a record,
as described in :pep:`376`.

Typical usage::

    Hash.parse("sha256=Y0sCextp4SQtQNU-MSs7SsdxD1W-gfKJtUlEbvZ3i-4")

:param h: a name=value string
r6   )split)clsrW   r)   r*   s   &&  r   parse
Hash.parseC   s      ggc1o4r   r1   N)r   r   r   r   r    r   r7   r   rC   rT   classmethodr[   r!   r"   )r%   s   @r   r   r      sL     9
 
+ +A AE
# #    r   c                      a a ] tR t^Tt oRtV3R lV 3R lltRV3R lR lltV3R lR ltR tV3R	 lR
 lt	]
V3R lR l4       tRtVtV ;t# )r   zxRepresents a single record in a RECORD file.

A list of :py:class:`RecordEntry` objects fully represents a RECORD file.
c                P   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RR/# )r(   pathhash_sizer+   N)r-   r   r   int)r   r%   s   "r   r.   RecordEntry.__annotate__Z   s2      S $ x} QU r   c                H   < \         SV `  4        Wn        W n        W0n        R# )a  Construct a ``RecordEntry`` object.

Most consumers should use :py:meth:`RecordEntry.from_elements`, since no
validation or parsing is performed by this constructor.

:param path: file's path
:param hash\_: hash of the file's contents
:param size: file's size in bytes
N)r   r   r`   ra   rb   )r   r`   ra   rb   r   s   &&&&r   r   RecordEntry.__init__Z   s     		
	r   c                P   < V ^8  d   QhRS[ S[,          RS[S[S[S[3,          /# )r(   path_prefixr+   )r   r-   r   )r   r%   s   "r   r.   rd   j   s*     
 
(3- 
5c3;O 
r   c                T   Ve-   VP                  R4      '       g   Q hWP                  ,           pMV P                  p\        P                  R8X  d   VP	                  RR4      pT\        V P                  ;'       g    R4      V P                  e   \        V P                  4      3# R3# )zConvert this into a 3-element tuple that can be written in a RECORD file.

:param path_prefix: A prefix to attach to the path -- must end in `/`
:return: a (path, hash, size) row
/\ )endswithr`   ossepreplacer-   ra   rb   )r   rh   r`   s   && r   to_rowRecordEntry.to_rowj   s     "'',,,,*D99D 66T><<c*D 

  b!"ii3C		N
 	
 :<
 	
r   c                    < V ^8  d   QhRS[ /# r4   r,   )r   r%   s   "r   r.   rd      s     
 
# 
r   c                d    R P                  V P                  V P                  V P                  4      # )z-RecordEntry(path={!r}, hash_={!r}, size={!r}))r   r`   ra   rb   r   s   &r   r   RecordEntry.__repr__   s(    >EEIItzz499
 	
r   c                    \        V\        4      '       g   \        # V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P
                  VP
                  8H  # r>   )r?   r   r@   r`   ra   rb   rA   s   &&r   rC   RecordEntry.__eq__   s^    %--!!II# ( (

ekk)( (		UZZ'	
r   c                &   < V ^8  d   QhRS[ RS[/# rF   rH   )r   r%   s   "r   r.   rd      s      U t r   c                    V P                   e   \        V4      V P                   8w  d   R# V P                  '       d   V P                  P                  V4      # R# )zValidate that ``data`` matches this instance.

:param data: Contents of the file corresponding to this instance.
:return: whether ``data`` matches hash and size.
FT)rb   lenra   rT   )r   rG   s   &&r   rT   RecordEntry.validate   sA     99 SY$))%;:::::&&t,,r   c                0   < V ^8  d   QhRS[ RS[ RS[ RR/# )r(   r`   ra   rb   r+   r   r,   )r   r%   s   "r   r.   rd      s/     (A (A (AS (A (A (Ar   c                t   . pV'       g   VP                  R4       V'       d    \        P                  V4      pMRpV'       d    \	        V4      pMRpV'       d   \        WV3VR7      hV ! VXXR7      #   \         d    TP                  R4        LWi ; i  \         d    TP                  R4        Lbi ; i)a  Build a RecordEntry object, from values of the elements.

Typical usage::

    for row in parse_record_file(f):
        record = RecordEntry.from_elements(row[0], row[1], row[2])

Meaning of each element is specified in :pep:`376`.

:param path: first element (file's path)
:param hash\_: second element (hash of the file's contents)
:param size: third element (file's size in bytes)
:raises InvalidRecordEntry: if any element is invalid
z`path` cannot be emptyz*`hash` does not follow the required formatNz`size` cannot be non-integerr   )r`   ra   rb   )appendr   r[   
ValueErrorrc   r	   )rZ   r`   ra   rb   r   
hash_value
size_values   &&&&   r   from_elementsRecordEntry.from_elements   s    " MM23L-1ZZ->
 J>,/I
 J$tD.A&QQJZ@@!  LJKL  ><=>s#   A6 B 6BBB76B7)ra   r`   rb   r>   )r   r   r   r   r    r   rq   r   rC   rT   r]   r   r!   r"   r#   r$   s   @@r   r   r   T   sS     
  
 
,
 


  (A (A (Ar   c                    V ^8  d   QhR\         \        ,          R\        \        \        \        \        3,          ,          /# )r(   rowsr+   )r   r-   r   r   )r   s   "r   r.   r.      s.      HSM huS#s]7K.L r   c              #  x  "   \         P                  ! V RRRR7      p\        V4       F  w  r#\        V4      ^8w  d)   RP	                  V\        V4      4      p\        W4.R7      hV^ ,          P                  RR4      V^ &   \        \        \        \        \        3,          \        V4      4      pVx  K  	  R	# 5i)
zParse a :pep:`376` RECORD.

Returns an iterable of 3-value tuples, that can be passed to
:any:`RecordEntry.from_elements`.

:param rows: iterator providing lines of a RECORD (no trailing newlines).
,"
)	delimiter	quotecharlineterminatorz)Row Index {}: expected 3 elements, got {}r   rk   rj   N)csvreader	enumeraterz   r   r	   rp   r   r   r-   tuple)r   r   	row_indexr   messager*   s   &     r   parse_record_filer      s      ZZs4PF(0	x=AAHH3x=G %hyII qk))$4U3S=)5?;  1s   B8B:)r   r   r	   r   )r    rP   r   rM   rn   typingr   r   r   r   r   __all__	Exceptionr	   r   r   r    r   r   <module>r      sL    M  
  	 < <
 
2  2 jqA qAhr   