ó
    ‘óýj�$  ã                   óf  • S r / SQrSSKrSSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJrJrJr  \(       a  S	S
KJr  S	SKJr  S	SKJr  S	SKJrJr   " S S\5      rSrSrS\S\4S jr  " S S5      r!  S"SSSSS\"S\S\#S\\SS4   4S jjr$ S#SSSSS\S\\%\S 4   SS4   4S! jjr&g)$z!Generates tarballs for Git trees.)ÚChunkedBytesIOÚUnsafeArchivePathErrorÚ
tar_streamé    N)Ú	Generator)Úclosing)ÚBytesIO)ÚSEEK_END)ÚTYPE_CHECKINGÚAnyÚcasté   )ÚBaseObjectStore)Ú	TreeEntry)Úcleanup_mode)ÚBlobÚTreec                   ó8   ^ • \ rS rSrSrS\SS4U 4S jjrSrU =r$ )r   é-   a  Raised when a tree contains a path that is unsafe to include in an archive.

Mirrors git's ``verify_path`` rejection (``error: invalid path``) for tree
entries whose names would escape the archive root or alias a special
directory on extraction. Examples include absolute paths, ``..`` or
``.git`` components, embedded backslashes, and NTFS alternate-data-stream
separators (``:``).
ÚpathÚreturnNc                 ó8   >• Xl         [        TU ]	  SU< 35        g)z1Initialize the exception with the offending path.zunsafe path in tree: N)r   ÚsuperÚ__init__)Úselfr   Ú	__class__s     €Ú:/usr/local/lib/python3.13/site-packages/dulwich/archive.pyr   ÚUnsafeArchivePathError.__init__7   s   ø€ àŒ	Ü‰ÑØ# D¡8Ð,õ	
ó    )r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úbytesr   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r   -   s    ø† ñð
˜Uð 
 t÷ 
õ 
r   r   )ó    ó   \ó   :)ó   .s   ..s   .gitr   r   r   c                 óÂ   • U (       d  g[          H
  nX;   d  M
    g   U R                  S5       H.  nUR                  5       R                  S5      nU[        ;   d  M.    g   g)aG  Return True if ``path`` should not be emitted into an archive.

Matches the spirit of git's ``verify_path``: absolute paths, ``.``/``..``/
``.git`` components (case-insensitive), embedded NUL bytes, backslashes,
and colons are all rejected, regardless of host platform, because the
resulting archive may be extracted anywhere.
Tó   /s   . F)Ú_UNSAFE_PATH_CHARSÚsplitÚlowerÚrstripÚ_INVALID_PATH_COMPONENTS)r   ÚchÚ	componentÚ
normalizeds       r   Ú_is_unsafe_archive_pathr5   H   s[   € ö Øß ˆØ�:Ùñ !ð —Z‘Z Ö%ˆ	ð —_‘_Ó&×-Ñ-¨eÓ4ˆ
ØÔ1Õ1Ùñ &ð r   c                   óL   • \ rS rSrSrS\\   SS4S jrS
S\S-  S\4S jjr	S	r
g)r   é_   a%  Turn a list of bytestrings into a file-like object.

This is similar to creating a `BytesIO` from a concatenation of the
bytestring list, but saves memory by NOT creating one giant bytestring
first::

    BytesIO(b''.join(list_of_bytestrings)) =~= ChunkedBytesIO(
        list_of_bytestrings)
Úcontentsr   Nc                 ó   • Xl         SU l        g)zDInitialize ChunkedBytesIO.

Args:
    contents: List of byte chunks
)r   r   N©r8   Úpos)r   r8   s     r   r   ÚChunkedBytesIO.__init__j   s   € ð !ŒØˆ�r   Úmaxbytesc                 óÜ  • Ub  US:  a  SnOUn/ nU R                   u  pEU[        U R                  5      :  a¥  [        U R                  U   5      U-
  nUb5  X&:  a0  UR                  U R                  U   XUU-    5        XR-  nXE4U l         ORUR                  U R                  U   US 5        Ub  X&-  nUS-  nSnXE4U l         U[        U R                  5      :  a  M¥  SR	                  U5      $ )z�Read bytes from the chunked stream.

Args:
    maxbytes: Maximum number of bytes to read (None for all)

Returns:
    Bytes read
Nr   r   r   )r;   Úlenr8   ÚappendÚjoin)r   r=   Ú	remainingÚbufÚchunkÚcursorÚchunk_remainders          r   ÚreadÚChunkedBytesIO.reads   sõ   € ð Ñ˜x¨!›|Ø‰Ià ˆIàˆØŸ™‰ˆà”c˜$Ÿ-™-Ó(Ó(Ü! $§-¡-°Ñ"6Ó7¸&Ñ@ˆOØÑ$¨Ó)DØ—
‘
˜4Ÿ=™=¨Ñ/°À)Ñ9KÐLÔMØÑ#�Ø!˜?�”Øà—
‘
˜4Ÿ=™=¨Ñ/°°Ð8Ô9ØÑ(ØÑ0�IØ˜‘
�Ø�Ø!˜?�”ð ”c˜$Ÿ-™-Ó(Õ(ð �x‰x˜‹}Ðr   r:   )N)r   r    r!   r"   r#   Úlistr$   r   ÚintrG   r%   © r   r   r   r   _   s:   † ñð  e¡ð °ô ñ˜S 4™Zð °5÷ ð r   r   Ústorer   Útreer   ÚmtimeÚprefixÚformatc              #   ót  #   • [        5       nU(       a  SU-   OSn[        [        [        [        R
                  5      " SXeS95       nUS:X  az  UR                  S5        UR                  S5      S:X  d   S	5       eUR                  S
5        UR                  [        R                  " SU5      5        UR                  S[        5        [        XU5       GH!  u  p‰U	R                  c   e X	R                     n
[        U
[         5      (       a  [#        U
R$                  5      nO[#        U
R'                  5       /5      n[        R(                  " 5       nUR+                  SS5      Ul        U
R/                  5       Ul        U	R2                  c   e[5        U	R2                  5      S-  Ul        X,l        UR9                  XË5        UR;                  5       v •  UR=                  S5        UR                  S5        GM$     SSS5        UR;                  5       v •  g! [         a     GMO  f = f! , (       d  f       N3= f7f)aV  Generate a tar stream for the contents of a Git tree.

Returns a generator that lazily assembles a .tar.gz archive, yielding it in
pieces (bytestrings). To obtain the complete .tar.gz binary file, simply
concatenate these chunks.

Args:
  store: Object store to retrieve objects from
  tree: Tree object for the tree root
  mtime: UNIX timestamp that is assigned as the modification time for
    all files, and the gzip header modification time if format='gz'
  prefix: Optional prefix to prepend to all paths in the archive
  format: Optional compression format for tarball
Returns:
  Bytestrings
zw:ÚwN)ÚnameÚmodeÚfileobjÚgzr   é   s   ‹zInvalid gzip headeré   z<Lzutf-8Úsurrogateescapeiÿ  )r   r   r   r   ÚtarfileÚopenÚseekrG   ÚwriteÚstructÚpackr	   Ú
_walk_treeÚshaÚKeyErrorÚ
isinstancer   r   ÚchunkedÚas_raw_stringÚTarInfoÚdecoderS   Ú
raw_lengthÚsizerT   r   rN   ÚaddfileÚgetvalueÚtruncate)rL   rM   rN   rO   rP   rC   rT   ÚtarÚentry_abspathÚentryÚblobÚdataÚinfos                r   r   r   •   sÃ  é € ô. ‹)€CÞ"ˆ4�&Š=¨€Dô 
””cœ7Ÿ<™<Ô(¨d¸ÑKÔ	LÐPSØ�T‹>ð �H‰H�QŒKØ—8‘8˜A“; +Ó-ÐDÐ/DÓDÐ-Ø�H‰H�QŒKØ�I‰I”f—k’k $¨Ó.Ô/Ø�H‰H�QœÔ!ä$.¨u¸F×$CÑ ˆMØ—9‘9Ñ(Ð(Ð(ðØŸY™YÑ'�ô
 ˜$¤×%Ñ%Ü% d§l¡lÓ3‘ô & t×'9Ñ'9Ó';Ð&<Ó=�ä—?’?Ó$ˆDà%×,Ñ,¨WÐ6GÓHˆDŒIØŸ™Ó)ˆDŒIØ—:‘:Ñ)Ð)Ð)ô % U§Z¡ZÓ0°5Ñ8ˆDŒIØŒJà�K‰K˜Ô#Ø—,‘,“.Ò Ø�L‰L˜ŒOØ�H‰H�Q�KñA %D÷ 
Mð\ �,‰,‹.Óøô; ó ó ðú÷# 
MÕ	LüsD   ‚AH8ÁB"H'Ã*HÃ8DH'Ç:H8È
H$ÈH'È#H$È$H'È'
H5È1H8Úrootr   c              #   ó   #   • UR                  5        Hä  nUR                  c   e[        UR                  5      (       a  [        UR                  5      e[        R
                  " X#R                  5      nUR                  c   e[        R                  " UR                  5      (       aJ  UR                  c   eXR                     n[        U[        5      (       a  [        XU5       Sh  v•N   MÝ  Mß  XC4v •  Mæ     g N7f)a  Recursively walk a dulwich Tree, yielding tuples of (absolute path, TreeEntry) along the way.

Raises:
  UnsafeArchivePathError: if a tree entry's name is unsafe to emit into
    an archive (matches the spirit of git's ``verify_path`` /
    ``error: invalid path``).
N)Ú	iteritemsr   r5   r   Ú	posixpathrA   rT   ÚstatÚS_ISDIRra   rc   r   r`   )rL   rM   rs   ro   rn   Úsubtrees         r   r`   r`   á   sÊ   é € ð —‘Ö!ˆØ�z‰zÑ%Ð%Ð%Ü" 5§:¡:×.Ñ.Ü(¨¯©Ó4Ð4Ü!Ÿš t¯Z©ZÓ8ˆØ�z‰zÑ%Ð%Ð%Ü�<Š<˜Ÿ
™
×#Ñ#Ø—9‘9Ñ(Ð(Ð(ØŸI™IÑ&ˆGÜ˜'¤4×(Ñ(Ü% e°mÓD×DÒDñ )ð !Ð(Ô(ò "ñ Eùs   ‚C'C>Ã)C<Ã*C>)r   Ú )r   )'r#   Ú__all__rv   rw   r^   rZ   Úcollections.abcr   Ú
contextlibr   Úior   Úosr	   Útypingr
   r   r   Úobject_storer   Úobjectsr   Úindexr   r   r   Ú
ValueErrorr   r-   r1   r$   Úboolr5   r   rJ   Ústrr   Útupler`   rK   r   r   Ú<module>rˆ      s  ðñ. (â
D€ã Û Û Û Ý %Ý Ý Ý ß +Ñ +æÝ-Ý"å ß ô
˜Zô 
ð, ,Ð à6Ð ð %ð ¨Dô ÷.3ñ 3ðt ØñIØðIà
ðIð ðIð ð	Ið
 ðIð ˆu�d˜DÐ Ñ!õIðZ ;>ñ)Øð)Ø$*ð)Ø27ð)àˆu�U˜KÐ'Ñ(¨$°Ð4Ñ5ö)r   