
    yIc&                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZddlm	Z	 dgZ
d Zd Zej        Z	 d Z G d d	          Z G d
 deej                  Z G d de          Z G d d          ZdS )    N   )text_encodingPathc                 H    t          j        t          |           dd          S )a2  
    Given a path with elements separated by
    posixpath.sep, generate all parents of that path.

    >>> list(_parents('b/d'))
    ['b']
    >>> list(_parents('/b/d/'))
    ['/b']
    >>> list(_parents('b/d/f/'))
    ['b/d', 'b']
    >>> list(_parents('b'))
    []
    >>> list(_parents(''))
    []
    r   N)	itertoolsislice	_ancestry)paths    -lib/python3.11/site-packages/zipp/__init__.py_parentsr      s      IdOOQ555    c              #      K   |                      t          j                  } | r?| t          j        k    r3| V  t          j        |           \  } }| r| t          j        k    -dS dS dS dS )aR  
    Given a path with elements separated by
    posixpath.sep, generate all elements of that path

    >>> list(_ancestry('b/d'))
    ['b/d', 'b']
    >>> list(_ancestry('/b/d/'))
    ['/b/d', '/b']
    >>> list(_ancestry('b/d/f/'))
    ['b/d/f', 'b/d', 'b']
    >>> list(_ancestry('b'))
    ['b']
    >>> list(_ancestry(''))
    []
    N)rstrip	posixpathsepsplit)r
   tails     r   r	   r	   #   s        ;;y}%%D
 +49=( +


_T**
d  +49=( + + + + + + + + +r   c                 P    t          j        t          |          j        |           S )zZ
    Return items in minuend not in subtrahend, retaining order
    with O(1) lookup.
    )r   filterfalseset__contains__)minuend
subtrahends     r   _differencer   =   s     
  Z!=wGGGr   c                   2     e Zd ZdZ fdZd Z fdZ xZS )InitializedStatez?
    Mix-in to save the initialization state for pickling.
    c                 V    || _         || _         t                      j        |i | d S N)_InitializedState__args_InitializedState__kwargssuper__init__)selfargskwargs	__class__s      r   r"   zInitializedState.__init__J   s3    $)&)))))r   c                     | j         | j        fS r   )r   r    r#   s    r   __getstate__zInitializedState.__getstate__O   s    {DM))r   c                 D    |\  }} t                      j        |i | d S r   )r!   r"   )r#   stater$   r%   r&   s       r   __setstate__zInitializedState.__setstate__R   s.    f$)&)))))r   )__name__
__module____qualname____doc__r"   r)   r,   __classcell__r&   s   @r   r   r   E   sj         * * * * *
* * ** * * * * * * * *r   r   c                   Z     e Zd ZdZed             Z fdZd Zd Ze	d             Z
 xZS )CompleteDirszk
    A ZipFile subclass that ensures that implied directories
    are always included in the namelist.
    c                     t           j                            t          t          |                     }d |D             }t          t          ||                     S )Nc              3   4   K   | ]}|t           j        z   V  d S r   )r   r   ).0ps     r   	<genexpr>z-CompleteDirs._implied_dirs.<locals>.<genexpr>`   s)      661y}$666666r   )r   chainfrom_iterablemapr   _deduper   )namesparentsas_dirss      r   _implied_dirszCompleteDirs._implied_dirs]   sL    ///He0D0DEE66g666{7E22333r   c                     t          t          |                                           }|t          |                     |                    z   S r   )r!   r4   namelistlistrA   )r#   r>   r&   s     r   rC   zCompleteDirs.namelistc   s?    lD))2244tD..u556666r   c                 D    t          |                                           S r   )r   rC   r(   s    r   	_name_setzCompleteDirs._name_setg   s    4==??###r   c                 P    |                                  }|dz   }||vo||v }|r|n|S )zx
        If the name represents a directory, return that name
        as a directory (with the trailing slash).
        /)rF   )r#   namer>   dirname	dir_matchs        r   resolve_dirzCompleteDirs.resolve_dirj   s?    
   *%:'U*:	#-ww-r   c                     t          |t                    r|S t          |t          j                  s | |          S d|j        vrt          } | |_        |S )zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        r)
isinstancer4   zipfileZipFilemoder&   )clssources     r   makezCompleteDirs.maket   s`     fl++ 	M&'/22 	3v;; fk! 	Cr   )r-   r.   r/   r0   staticmethodrA   rC   rF   rL   classmethodrU   r1   r2   s   @r   r4   r4   W   s         
 4 4 \4
7 7 7 7 7$ $ $. . .   [    r   r4   c                   ,     e Zd ZdZ fdZ fdZ xZS )
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    c                     t          j        t                    5  | j        cd d d            S # 1 swxY w Y   t	          t
          |                                           | _        | j        S r   )
contextlibsuppressAttributeError_FastLookup__namesr!   rY   rC   r#   r&   s    r   rC   zFastLookup.namelist   s     00 	  	 <	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 Z..7799|   /33c                     t          j        t                    5  | j        cd d d            S # 1 swxY w Y   t	          t
          |                                           | _        | j        S r   )r[   r\   r]   _FastLookup__lookupr!   rY   rF   r_   s    r   rF   zFastLookup._name_set   s     00 	! 	!=	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!j$//99;;}r`   )r-   r.   r/   r0   rC   rF   r1   r2   s   @r   rY   rY      s[         
            r   rY   c                   &   e Zd ZdZdZd"dZd Zd Zd#dd	d
Ze	d             Z
e	d             Ze	d             Ze	d             Ze	d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd  ZeZ e	d!             Z!dS )$r   u4  
    A pathlib-compatible interface for zip files.

    Consider a zip file with this structure::

        .
        ├── a.txt
        └── b
            ├── c.txt
            └── d
                └── e.txt

    >>> data = io.BytesIO()
    >>> zf = zipfile.ZipFile(data, 'w')
    >>> zf.writestr('a.txt', 'content of a')
    >>> zf.writestr('b/c.txt', 'content of c')
    >>> zf.writestr('b/d/e.txt', 'content of e')
    >>> zf.filename = 'mem/abcde.zip'

    Path accepts the zipfile object itself or a filename

    >>> root = Path(zf)

    From there, several path operations are available.

    Directory iteration (including the zip file itself):

    >>> a, b = root.iterdir()
    >>> a
    Path('mem/abcde.zip', 'a.txt')
    >>> b
    Path('mem/abcde.zip', 'b/')

    name property:

    >>> b.name
    'b'

    join with divide operator:

    >>> c = b / 'c.txt'
    >>> c
    Path('mem/abcde.zip', 'b/c.txt')
    >>> c.name
    'c.txt'

    Read text:

    >>> c.read_text()
    'content of c'

    existence:

    >>> c.exists()
    True
    >>> (b / 'missing.txt').exists()
    False

    Coercion to string:

    >>> import os
    >>> str(c).replace(os.sep, posixpath.sep)
    'mem/abcde.zip/b/c.txt'

    At the root, ``name``, ``filename``, and ``parent``
    resolve to the zipfile. Note these attributes are not
    valid and will raise a ``ValueError`` if the zipfile
    has no filename.

    >>> root.name
    'abcde.zip'
    >>> str(root.filename).replace(os.sep, posixpath.sep)
    'mem/abcde.zip'
    >>> str(root.parent)
    'mem'
    z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r}) c                 R    t                               |          | _        || _        dS )aX  
        Construct a Path from a ZipFile or filename.

        Note: When the source is an existing ZipFile object,
        its type (__class__) will be mutated to a
        specialized type. If the caller wishes to retain the
        original type, the caller should either create a
        separate ZipFile object or pass a filename.
        N)rY   rU   rootat)r#   rf   rg   s      r   r"   zPath.__init__   s"     OOD))	r   c                 h    | j         |j         urt          S | j        | j        f|j        |j        fk    S )zU
        >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
        False
        )r&   NotImplementedrf   rg   )r#   others     r   __eq__zPath.__eq__   s8    
 >0 	"!!	47#
EH'===r   c                 8    t          | j        | j        f          S r   )hashrf   rg   r(   s    r   __hash__zPath.__hash__  s    TY()))r   rN   Npwdc                   |                                  rt          |           |d         }|                                 s|dk    rt          |           | j                            | j        ||          }d|v r|s|rt          d          |S t          |	                    d                    |d<   t          j        |g|R i |S )z
        Open this entry as text or binary following the semantics
        of ``pathlib.Path.open()`` by passing arguments through
        to io.TextIOWrapper().
        r   rN   ro   bz*encoding args invalid for binary operationencoding)is_dirIsADirectoryErrorexistsFileNotFoundErrorrf   openrg   
ValueErrorr   getioTextIOWrapper)r#   rR   rp   r$   r%   zip_modestreams          r   rx   z	Path.open  s     ;;== 	*#D)))7{{}} 	*S 	*#D)))s;;$; 	G Ov O !MNNNM!.vzz*/E/E!F!FF:8888888r   c                 V    t          j        | j                  j        p| j        j        S r   )pathlibr   rg   rI   filenamer(   s    r   rI   z	Path.name  !    |DG$$)?T]-??r   c                 V    t          j        | j                  j        p| j        j        S r   )r   r   rg   suffixr   r(   s    r   r   zPath.suffix  s!    |DG$$+Ct}/CCr   c                 V    t          j        | j                  j        p| j        j        S r   )r   r   rg   suffixesr   r(   s    r   r   zPath.suffixes   s!    |DG$$-G1GGr   c                 V    t          j        | j                  j        p| j        j        S r   )r   r   rg   stemr   r(   s    r   r   z	Path.stem$  r   r   c                 n    t          j        | j        j                                      | j                  S r   )r   r   rf   r   joinpathrg   r(   s    r   r   zPath.filename(  s'    |DI.//88AAAr   c                     t          |                    d                    |d<    | j        dg|R i |5 }|                                cd d d            S # 1 swxY w Y   d S )Nrs   rN   )r   rz   rx   read)r#   r$   r%   strms       r   	read_textzPath.read_text,  s    *6::j+A+ABBzTYs,T,,,V,, 	99;;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAc                     |                      d          5 }|                                cd d d            S # 1 swxY w Y   d S )Nrb)rx   r   )r#   r   s     r   
read_byteszPath.read_bytes1  s~    YYt__ 	99;;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   7;;c                     t          j        |j                            d                    | j                            d          k    S NrH   )r   rJ   rg   r   )r#   r
   s     r   	_is_childzPath._is_child5  s4     !4!4559L9LLLr   c                 8    |                      | j        |          S r   )r&   rf   )r#   rg   s     r   _nextz
Path._next8  s    ~~di,,,r   c                 F    | j          p| j                             d          S r   )rg   endswithr(   s    r   rt   zPath.is_dir;  s!    7{3dg..s333r   c                 T    |                                  o|                                  S r   )rv   rt   r(   s    r   is_filezPath.is_file>  s     {{}}2T[[]]!22r   c                 B    | j         | j                                        v S r   )rg   rf   rF   r(   s    r   rv   zPath.existsA  s    w$)--////r   c                     |                                  st          d          t          | j        | j                                                  }t          | j        |          S )NzCan't listdir a file)rt   ry   r<   r   rf   rC   filterr   )r#   subss     r   iterdirzPath.iterdirD  sR    {{}} 	534444:ty113344dnd+++r   c                 Z    t          j        | j                                      |          S r   )r   r   rg   match)r#   path_patterns     r   r   z
Path.matchJ  s"    |DG$$**<888r   c                     dS )z]
        Return whether this path is a symlink. Always false (python/cpython#82102).
        F r(   s    r   
is_symlinkzPath.is_symlinkM  s	     ur   c              #      K   |                                  D ]4}|V  |                                r|                                E d {V  5d S r   )r   rt   _descendants)r#   childs     r   r   zPath._descendantsS  se      \\^^ 	0 	0EKKK||~~ 0 --/////////	0 	0r   c                      |s"t          d                    |                    t          j        t	          j        |                    j         fd                                 D             S )NzUnacceptable pattern: {!r}c              3   r   K   | ]1} t          |                                                  -|V  2d S r   )strrelative_to)r7   r   matchesr#   s     r   r9   zPath.glob.<locals>.<genexpr>^  s]       
 
ws5,,T223344

 
 
 
 
 
r   )ry   formatrecompilefnmatch	translate	fullmatchr   )r#   patternr   s   ` @r   globz	Path.globY  s     	K9@@IIJJJ*W.w7788B
 
 
 
 
**,,
 
 
 	
r   c                 2    |                      d|           S )Nz**/)r   )r#   r   s     r   rglobz
Path.rglobd  s    yyw)))r   c                 p    t          j        t          |           t           |j        |                     S r   )r   relpathr   r   )r#   rj   extras      r   r   zPath.relative_tog  s,     TC0F,G,GHHHr   c                 J    t          j        | j        j        | j                  S r   )r   joinrf   r   rg   r(   s    r   __str__zPath.__str__j  s    ~di0$':::r   c                 8    | j                             |           S )Nr(   )_Path__reprr   r(   s    r   __repr__zPath.__repr__m  s    {!!t!,,,r   c                     t          j        | j        g|R  }|                     | j                            |                    S r   )r   r   rg   r   rf   rL   )r#   rj   nexts      r   r   zPath.joinpathp  s=    ~dg....zz$)//55666r   c                     | j         s| j        j        S t          j        | j                             d                    }|r|dz  }|                     |          S r   )rg   r   parentr   rJ   r   r   )r#   	parent_ats     r   r   zPath.parentv  sY    w 	(=''%dgnnS&9&9::	 	Izz)$$$r   )rd   )rN   )"r-   r.   r/   r0   r   r"   rk   rn   rx   propertyrI   r   r   r   r   r   r   r   r   rt   r   rv   r   r   r   r   r   r   r   r   r   r   __truediv__r   r   r   r   r   r      s6       K KZ NF   > > >* * *9 9 9 9 9 9( @ @ X@ D D XD H H XH @ @ X@ B B XB  
  M M M- - -4 4 43 3 30 0 0, , ,9 9 9  0 0 0	
 	
 	
* * *I I I; ; ;- - -7 7 7 K% % X% % %r   )r{   r   rP   r   r[   r   r   r   py310compatr   __all__r   r	   dictfromkeysr=   r   r   rQ   r4   rY   r   r   r   r   <module>r      sk   				               				  & & & & & & (6 6 6&+ + +, - /H H H* * * * * * * *$. . . . .#W_ . . .b       &b% b% b% b% b% b% b% b% b% b%r   