+
    i                         R t ^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHtHt . ROt]	 ! R
 R]4      4       t]	 ! R R4      4       t]	 ! R R	4      4       tR R ltR# )zGProvides an object-oriented model for handling :pep:`376` RECORD files.N)IterableIterator)	dataclass)Path)BinaryIOcast)copyfileobj_with_hashingget_stream_lengthHashInvalidRecordEntryRecordEntryc                   N   a a ] tR t^t oRtV3R lV 3R lltV3R ltRtVtV ;t	# )r   zPRaised when a RecordEntry is not valid, due to improper element values or count.c                   < V ^8  d   QhRR/# )   returnN )format__classdict__s   "B/root/miniconda3/lib/python3.14/site-packages/installer/records.py__annotate__InvalidRecordEntry.__annotate__   s     1 1t 1    c                X   < \         SV `  R P                  V P                  4      4       R# )z, N)super__init__joinissues)self	__class__s   &r   __post_init__ InvalidRecordEntry.__post_init__   s    4;;/0r   c                R   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )r   elementsr   )r   str)r   r   s   "r   r   r      s'      sm	 
 SM r   r   )
__name__
__module____qualname____firstlineno____doc__r   __annotate_func____static_attributes____classdictcell____classcell__)r   r   s   @@r   r   r      s     Z
1 1  r   c                   t   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4       tV 3R lt	R	t
V tR
# )r
   zRepresents the "hash" element of a RecordEntry.

Most consumers should use :py:meth:`Hash.parse` instead, since no
validation or parsing is performed by this constructor.
c                    < V ^8  d   QhRS[ /# r   r   r#   )r   r   s   "r   r   Hash.__annotate__/   s     + + +r   c                8    V P                    R V P                   2# )=)namevaluer   s   &r   __str__Hash.__str__/   s    ))Adjj\**r   c                &   < V ^8  d   QhRS[ RS[/# r   datar   bytesbool)r   r   s   "r   r   r1   2   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.
asciir3   )	hashlibnewr4   digestbase64urlsafe_b64encodedecoderstripr5   )r   r;   rC   r5   s   &&  r   validateHash.validate2   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
   r0   )r   r   s   "r   r   r1   =   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
r3   )split)clsrK   r4   r5   s   &&  r   parse
Hash.parse<   s      ggc1o4r   c                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )r   r4   r5   r0   )r   r   s   "r   r   r1   !   s      I  J r   r   N)r$   r%   r&   r'   r(   r7   rH   classmethodrO   r)   r*   r+   r   s   @r   r
   r
   !   sC      % + +# #    9  r   c                      a  ] tR t^Mt o Rt   RV 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	]
V 3R lR l4       tV 3R ltRtV tR# )r   zRepresents a single record in a RECORD file.

A list of :py:class:`RecordEntry` objects fully represents a RECORD file.

Most consumers should use :py:meth:`RecordEntry.from_elements`, since no
validation or parsing is performed by this constructor.
Nc                N   < V ^8  d   QhRS[ R,          RS[S[ S[ S[ 3,          /# )r   path_prefixNr   )r#   tuple)r   r   s   "r   r   RecordEntry.__annotate__`   s*     
 
#* 
c3m8L 
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
/\ )endswithpathossepreplacer#   hash_size)r   rV   r^   s   && r   to_rowRecordEntry.to_row`   s     "'',,,,*D99D 66T><<c*D 

  b!"ii3C		N
 	
 :<
 	
r   c                    < V ^8  d   QhRS[ /# r/   r0   )r   r   s   "r   r   rX   v   s     
 
# 
r   c                \    R V P                   : RV P                  : RV P                  : R2# )zRecordEntry(path=z, hash_=z, size=)r^   rb   rc   r6   s   &r   __repr__RecordEntry.__repr__v   s,    		}HTZZN'$))VWX	
r   c                &   < V ^8  d   QhRS[ RS[/# )r   otherr   )objectr>   )r   r   s   "r   r   rX   {   s     
 
F 
t 
r   c                    \        V\        4      '       g   \        # V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P
                  VP
                  8H  # N)
isinstancer   NotImplementedr^   rb   rc   )r   rm   s   &&r   __eq__RecordEntry.__eq__{   s^    %--!!II# ( (

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

.. attention::
    .. deprecated:: 1.0.0
        Use :py:meth:`validate_stream` instead, with ``BytesIO(data)``.

:param data: Contents of the file corresponding to this instance.
:return: whether ``data`` matches hash and size.
FT)rc   lenrb   rH   )r   r;   s   &&r   rH   RecordEntry.validate   sA     99 SY$))%;:::::&&t,,r   c                &   < V ^8  d   QhRS[ RS[/# )r   streamr   )r   r>   )r   r   s   "r   r   rX      s      h 4 r   c           	        V P                   e   \        \        P                  4      P	                  R4      ;_uu_ 4       p\        V\        RV4      V P                   P                  4      w  r4RRR4       V P                  e   XV P                  8w  d   R# V P                   P                  X8H  # V P                  e*   V P                   e   Q h\        V4      pW@P                  8H  # R#   + '       g   i     L; i)zValidate that data read from stream matches this instance.

:param stream: Representing the contents of the file.
:return: Whether data read from stream matches hash and size.
Nwbr   FT)rb   r   r_   devnullopenr   r   r4   rc   r5   r	   )r   rz   
new_targetrb   rc   s   &&   r   validate_streamRecordEntry.validate_stream   s     ::!bjj!&&t,,
6DZ8$**// -
 yy$):::##u,,YY"::%%%$V,D99$$ -,s   .C((C8	c                0   < V ^8  d   QhRS[ RS[ RS[ RR/# )r   r^   rb   rc   r   r   r0   )r   r   s   "r   r   rX      s/     *A *A *AS *A *A *Ar   c                   . pV'       g   VP                  R4       RpV'       dW    \        P                  V4      pVP                  \        P
                  9  d"   VP                  RVP                   R24       RpV'       d    \        V4      pMRpV'       d   \        WV3VR7      hV ! WXR7      #   \         d    TP                  R4        LVi ; i  \         d    TP                  R4        Lai ; 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 emptyNzinvalid hash algorithm ''z*`hash` does not follow the required formatz`size` cannot be non-integerr"   r   ri   )	appendr
   rO   r4   rA   algorithms_available
ValueErrorintr   )rN   r^   rb   rc   r   
hash_value
size_values   &&&&   r   from_elementsRecordEntry.from_elements   s    " MM23"&
L!ZZ.
??'*F*FFMM$<Z__<MQ"OP!%J >),T
 J$tD.A&QQZ@@  LJKL  ><=>s$   AB4 C 4CCC54C5c                Z   < V ^8  d   Qh/ S[ ;R&   S[R,          ;R&   S[R,          ;R&   # )r   r^   Nrb   rc   )r#   r
   r   )r   r   s   "r   r   rX   M   s3      I  $;   *! r   r   rp   )r$   r%   r&   r'   r(   rd   rj   rs   rH   r   rR   r   r)   r*   r+   rS   s   @r   r   r   M   si       '  
 
,
 


 
 $ . *A *AC  r   c                    V ^8  d   QhR\         \        ,          R\        \        \        \        \        3,          ,          /# )r   rowsr   )r   r#   r   rW   )r   s   "r   r   r      s.      HSM huS#s]7K.L r   c              #  0  "   \         P                  ! V RRRR7      p\        V4       Fh  w  r#\        V4      ^8w  d   RV R\        V4       2p\	        W4.R7      hV^ ,          P                  RR	4      V^ &   \        R
\        V4      4      pVx  Kj  	  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 z: expected 3 elements, got r   r[   rZ   ztuple[str, str, str]N)csvreader	enumeraterw   r   ra   r   rW   )r   r   	row_indexr"   messager5   s   &     r   parse_record_filer      s      ZZs4PF(0	x=A"9+-HXXG$hyII qk))$4+U8_=  1s   BB)r
   r   r   r   )r(   rD   r   rA   r_   collections.abcr   r   dataclassesr   pathlibr   typingr   r   installer.utilsr   r	   __all__	Exceptionr   r
   r   r   r   r   r   <module>r      s    M  
  	 . !  ! G 1 1 1 (  (  ( V JA JA JAZr   