
    3i                       S r SSKJr  SSK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  \R                  " S5      r\R                  " \5         SSKr " S S\5      r " S	 S
\R&                  5      r\R*                  S4SS. SS jjjr S SS jjrS\R0                  4SS.   SS jjjrg! \ a    SSKr\R"                  " S5        Sr N|f = f)z7
Unpack conda packages without using a temporary file.
    )annotationsN)	Generator)Enumz@zstandard could not be imported. Running without .conda support.c                  "    \ rS rSrSrSrS rSrg)CondaComponent   pkginfoc                    U R                   $ N)value)selfs    Ilib/python3.13/site-packages/conda_package_streaming/package_streaming.py__str__CondaComponent.__str__"   s    zz     N)__name__
__module____qualname____firstlineno__r	   r
   r   __static_attributes__r   r   r   r   r      s    
CDr   r   c                  @   ^  \ rS rSrSS.SU 4S jjjrS rS rSrU =r$ )TarfileNoSameOwner&   N)umaskc               P   > [         TU ]  " U0 UD6  Ub  Xl        g[        U l        g)a  Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
read from an existing archive, 'a' to append data to an existing
file or 'w' to create a new file overwriting an existing one. `mode'
defaults to 'r'.
If `fileobj' is given, it is used for reading or writing data. If it
can be determined, `mode' is overridden by `fileobj's mode.
`fileobj' is not closed, when TarFile is closed.
N)super__init__UMASKr   )r   r   argskwargs	__class__s       r   r   TarfileNoSameOwner.__init__'   s'     	$)&)#/U
U
r   c                    g)z
Override chown to be a no-op, since we don't want to preserve ownership
here. (tarfile.TarFile only lets us toggle all of (chown, chmod, mtime))
Nr   )r   tarinfo
targetpathnumeric_owners       r   chownTarfileNoSameOwner.chown3   s    
 	r   c                    UR                   c  g [        R                  " X!R                   SU R                  ) -  -  5        g! [         a  n[
        R                  " S5      UeSnAff = f)zL
Set file permissions of targetpath according to tarinfo, respecting
umask.
Nzcould not change mode)modeoschmodr   OSErrortarfileExtractError)r   r&   r'   es       r   r/   TarfileNoSameOwner.chmod:   s]    
 <<	GHHZ

{1C!DE 	G&&'>?QF	Gs   1A 
A(A##A()r   z
int | None)	r   r   r   r   r   r)   r/   r   __classcell__)r#   s   @r   r   r   &   s!    26 
; 
;G Gr   r   Fzutf-8)encodingc             #     #     U" U SUS9 nU H  nXE4v   M
     SSS5        U(       a  U R                  5         gg! , (       d  f       N'= f! U(       a  U R                  5         f f = f7f)z
Yield (tar, member) from fileobj.

Args:
    fileobj: file-like object

    encoding: "utf-8" passed to TarFile.open(); can be changed for testing.
zr|)fileobjr-   r6   N)close)r8   tarfile_openclosefdr6   tarmembers         r   tar_generatorr>   H   s`     'xHCk!  I MMO 	 IH MMO s/   A*A <A A*
A
A A''A*c                    Sn[        XU5      $ )a  
Yield members from conda's embedded info/ tarball.

For .tar.bz2 packages, yield all members.

Yields (tar, member) tuples. You must only use the current member to
prevent tar seeks and scans.

To extract to disk, it's possible to call ``tar.extractall(path)`` on the
first result and then ignore the rest of this generator. ``extractall`` takes
care of some directory permissions/mtime issues, compared to ``extract`` or
writing out the file objects yourself.
r
   )stream_conda_component)filenamer8   	components      r   stream_conda_inforC   ^   s      I!(Y??r   c                  [        U 5      R                  S5      (       Ga  [        c  [        S5      e[        R
                  " U=(       d    U 5      n[        R                  R                  U 5      R                  S5      u  n  nU SU 3nUR                  5        Vs/ s H&  oR                  R                  U5      (       d  M$  UPM(     n	nU	(       d  [        SU SU  35      e[        U	5      S:X  d   e[        R                  " 5       R!                  UR#                  U	S	   5      5      n
OI[        U 5      R                  S
5      (       a  [$        R"                  " U=(       d    U SS9n
O['        S5      e[)        XSL US9$ s  snf )a  
Yield members from .conda's embedded {component}- tarball. "info" or "pkg".

For .tar.bz2 packages, yield all members.

Yields (tar, member) tuples. You must only use the current member to
prevent tar seeks and scans.

To extract to disk, it's possible to call ``tar.extractall(path)`` on the
first result and then ignore the rest of this generator. ``extractall`` takes
care of some directory permissions/mtime issues, compared to ``extract`` or
writing out the file objects yourself.
z.condaNz(Cannot unpack `.conda` without zstandard.-zdidn't find z component in    r   z.tar.bz2rb)r-   zunsupported file extension)r;   r6   )strendswith	zstandardRuntimeErrorzipfileZipFiler.   pathbasename
rpartitioninfolistrA   
startswithLookupErrorlenZstdDecompressorstream_readeropenbz2
ValueErrorr>   )rA   r8   rB   r6   zfstem_component_namer
   component_filenamereaders              r   r@   r@   r   sO   ( 8}h''IJJ__W01WW%%h/::3?
a%;av.[[]
*Tmm.F.F~.VD] 	 
 "^,<N8*UVV%&!+++++-;;GG&q)*
 
X		
	+	+'-XD9566D8LL
s   #FF)return2Generator[tuple[tarfile.TarFile, tarfile.TarInfo]]r   )rB   zCondaComponent | strra   rb   )__doc__
__future__r   rY   r.   os.pathr1   rM   collections.abcr   enumr   r   r    rK   ImportErrorwarningswarnr   TarFiler   rX   r>   rC   r	   r@   r   r   r   <module>rl      s    # 
 	    %  	 T G GF -115NU7. @7@, &4&8&8(M
 (M $(M 8(My  MMTUIs   B. .CC