
    Og                     l    d dl m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e	Z
d Zd Z G d d      Zy)    )divisionNc                 B    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(''))
    []
       N)	itertoolsislice	_ancestrypaths    ?/var/www/djangounited/venv/lib/python3.12/site-packages/zipp.py_parentsr      s      IdOQ55    c              #      K   | j                  t        j                        } | rH| t        j                  k7  r4|  t        j                  |       \  } }| r| t        j                  k7  r2yyyyw)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   $   sV       ;;y}}%D
49==(
__T*
d 49==($($s   A&A-)A-c                       e Zd ZdZdZd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eZed        Zed        Zed        Zd Zej:                  dk  reZyy)Pathu  
    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 = '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('abcde.zip', 'a.txt')
    >>> b
    Path('abcde.zip', 'b/')

    name property:

    >>> b.name
    'b'

    join with divide operator:

    >>> c = b / 'c.txt'
    >>> c
    Path('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:

    >>> str(c)
    'abcde.zip/b/c.txt'
    z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})c                     t        |t        j                        r|n#t        j                  | j                  |            | _        || _        y N)
isinstancezipfileZipFile_pathlib_compatrootat)selfr   r   s      r   __init__zPath.__init__}   s>     $0 !5!5d!;< 		
 r   c                 X    	 | j                         S # t        $ r t        |       cY S w xY w)zu
        For path-like objects, convert to a filename for compatibility
        on Python 3.6.1 and earlier.
        )
__fspath__AttributeErrorstrr	   s    r   r   zPath._pathlib_compat   s-    	??$$ 	t9	s    ))c                 j    t        j                  | j                  j                  | j                        S r   )	functoolspartialr   openr   r   s    r   r'   z	Path.open   s!      99r   c                 ^    t        j                  | j                  j                  d            S N/)r   basenamer   r   r(   s    r   namez	Path.name   s     !!$''.."566r   c                     | j                         5 }t        j                  |g|i |j                         cd d d        S # 1 sw Y   y xY wr   )r'   ioTextIOWrapperread)r   argskwargsstrms       r   	read_textzPath.read_text   sG    YY[ 	BD##D:4:6:??A	B 	B 	Bs   'AAc                 n    | j                         5 }|j                         cd d d        S # 1 sw Y   y xY wr   )r'   r1   )r   r4   s     r   
read_byteszPath.read_bytes   s+    YY[ 	D99;	 	 	s   +4c                     t        j                  |j                  j                  d            | j                  j                  d      k(  S r*   )r   dirnamer   r   )r   r
   s     r   	_is_childzPath._is_child   s2      !459LLLr   c                 .    t        | j                  |      S r   )r   r   )r   r   s     r   _nextz
Path._next   s    DIIr""r   c                 V    | j                    xs | j                   j                  d      S r*   )r   endswithr(   s    r   is_dirzPath.is_dir   s"    77{3dgg..s33r   c                 $    | j                          S r   )r?   r(   s    r   is_filezPath.is_file   s    ;;=  r   c                 :    | j                   | j                         v S r   )r   _namesr(   s    r   existszPath.exists   s    ww$++-''r   c                     | j                         st        d      t        | j                  | j	                               }t        | j                  |      S )NzCan't listdir a file)r?   
ValueErrormapr<   rC   filterr:   )r   subss     r   iterdirzPath.iterdir   s>    {{}3444::t{{}-dnnd++r   c                 j    t        j                  | j                  j                  | j                        S r   )r   joinr   filenamer   r(   s    r   __str__zPath.__str__   s!    ~~dii00$''::r   c                 :    | j                   j                  |       S )Nr(   )_Path__reprformatr(   s    r   __repr__zPath.__repr__   s    {{!!t!,,r   c                    | j                  |      }t        j                  | j                  |      }t        j                  | j                  |d      }| j	                         }| j                  ||vr
||v r|      S |      S )N )r   r   rL   r   rC   r<   )r   addnextnext_dirnamess        r   joinpathzPath.joinpath   sm    ""3'~~dggs+>>$''33zzd%&7H<M(XXSWXXr   c                 @     t        j                   fd D              S )Nc              3   V   K   | ]   }t        |      D ]  }|d z   vr|d z     " yw)r+   N)r   ).0r-   parentrX   s      r   	<genexpr>z%Path._implied_dirs.<locals>.<genexpr>   sB      .
"4..
 |5( SL.
.
s   &))more_itertoolsunique_everseen)rX   s   `r   _implied_dirszPath._implied_dirs   s#    -- .
.
 
 	
r   c                 <    |t        | j                  |            z   S r   )listra   )clsrX   s     r   _add_implied_dirszPath._add_implied_dirs   s    tC--e4555r   c                     t        j                  | j                  j                  d            }|r|dz  }| j	                  |      S r*   )r   r9   r   r   r<   )r   	parent_ats     r   r]   zPath.parent   s;    %%dggnnS&9:	Izz)$$r   c                 T    | j                  | j                  j                               S r   )re   r   namelistr(   s    r   rC   zPath._names   s     %%dii&8&8&:;;r   )   N)rT   )__name__
__module____qualname____doc__rP   r   staticmethodr   propertyr'   r-   r5   r7   r:   r<   r?   rA   rD   rJ   rN   rR   rY   __truediv__ra   classmethodre   r]   rC   sysversion_info__div__ r   r   r   r   :   s    >@ NF   : : 7 7BM#4!(,;-Y K
 
 6 6 % %< $ r   r   )
__future__r   r/   rs   r   r   r%   r   r_   type__metaclass__r   r   r   rv   r   r   <module>rz      s:      	 
     6&+,b br   