HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/zipp/__pycache__/__init__.cpython-310.pyc
o

;j�-�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZdgZdd	�Zd
d�ZejZ	dd
�ZGdd�d�ZGdd�deej�ZGdd�de�Zddd�ZGdd�d�ZdS)z�
A Path-like interface for zipfiles.

This codebase is shared between zipfile.Path in the stdlib
and zipp in PyPI. See
https://github.com/python/importlib_metadata/wiki/Development-Methodology
for more detail.
�N�)�none_as�save_method_args��
text_encoding)�
Translator�PathcCst�t|�dd�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(''))
    []
    rN)�	itertools�islice�	_ancestry)�path�r
�A/opt/saltstack/salt/lib/python3.10/site-packages/zipp/__init__.py�_parentssrccsB�|�tj�}|�tj�r|Vt�|�\}}|�tj�s
dSdS)a�
    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(''))
    []

    Multiple separators are treated like a single.

    >>> list(_ancestry('//b//d///f//'))
    ['//b//d///f', '//b//d', '//b']
    N)�rstrip�	posixpath�sep�split)r�tailr
r
rr-s��rcCst�t|�j|�S)zZ
    Return items in minuend not in subtrahend, retaining order
    with O(1) lookup.
    )r	�filterfalse�set�__contains__)ZminuendZ
subtrahendr
r
r�_differenceLsrcs8eZdZdZe�fdd��Zdd�Z�fdd�Z�ZS)�InitializedStatez?
    Mix-in to save the initialization state for pickling.
    cst�j|i|��dS�N��super�__init__)�self�args�kwargs��	__class__r
rrY�zInitializedState.__init__cCs|jj|jjfSr)Z_saved___init__rr �rr
r
r�__getstate__]�zInitializedState.__getstate__cs|\}}t�j|i|��dSrr)r�staterr r!r
r�__setstate__`szInitializedState.__setstate__)	�__name__�
__module__�__qualname__�__doc__rrr%r(�
__classcell__r
r
r!rrTsrcsneZdZdZedd��Z�fdd�Zdd�Zdd	�Z�fd
d�Z	e
dd
��Ze
dej
dej
fdd��Z�ZS)�CompleteDirsa8
    A ZipFile subclass that ensures that implied directories
    are always included in the namelist.

    >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt']))
    ['foo/', 'foo/bar/']
    >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/']))
    ['foo/']
    cCs.tj�tt|��}dd�|D�}tt||��S)Ncss�|]}|tjVqdSr)rr)�.0�pr
r
r�	<genexpr>ss�z-CompleteDirs._implied_dirs.<locals>.<genexpr>)r	�chain�
from_iterable�mapr�_deduper)�names�parentsZas_dirsr
r
r�
_implied_dirspszCompleteDirs._implied_dirscst���}|t|�|��Sr)r�namelist�listr8)rr6r!r
rr9vs
zCompleteDirs.namelistcCst|���Sr)rr9r$r
r
r�	_name_setzszCompleteDirs._name_setcCs,|��}|d}||vo||v}|r|S|S)zx
        If the name represents a directory, return that name
        as a directory (with the trailing slash).
        �/)r;)r�namer6�dirnameZ	dir_matchr
r
r�resolve_dir}szCompleteDirs.resolve_dircsFzt��|�WSty"|�d�r||��vr�tj|d�YSw)z6
        Supplement getinfo for implied dirs.
        r<)�filename)r�getinfo�KeyError�endswithr;�zipfileZZipInfo)rr=r!r
rrA�s�zCompleteDirs.getinfocCs:t|t�r|St|tj�s||�Sd|jvrt}||_|S)zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        �r)�
isinstancer.rD�ZipFile�moder")�cls�sourcer
r
r�make�s

zCompleteDirs.make�zf�returncCs$|�|���D]}|�|d�q|S)z�
        Given a writable zip file zf, inject directory entries for
        any directories implied by the presence of children.
        �)r8r9Zwritestr)rIrLr=r
r
r�inject�szCompleteDirs.inject)r)r*r+r,�staticmethodr8r9r;r?rA�classmethodrKrDrGrOr-r
r
r!rr.es



 r.csHeZdZdZdd�Zej�fdd��Zdd�Zej�fdd	��Z	�Z
S)
�
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    cC�|jSr)�	_namelistr$r
r
rr9��zFastLookup.namelistc�
t���Sr)rr9r$r!r
rrT��
zFastLookup._namelistcCrSr)�_name_set_propr$r
r
rr;�rUzFastLookup._name_setcrVr)rr;r$r!r
rrX�rWzFastLookup._name_set_prop)r)r*r+r,r9�	functools�cached_propertyrTr;rXr-r
r
r!rrR�srRcOsd}t||�||fS)N�r)�encodingrr Zstack_levelr
r
r�_extract_text_encoding�sr]c@seZdZdZdZd=dd�Zdd�Zdd	�Zd>dd�d
d�Zdd�Z	e
dd��Ze
dd��Ze
dd��Z
e
dd��Ze
dd��Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�ZeZ e
d;d<��Z!dS)?ru#
    A :class:`importlib.resources.abc.Traversable` interface for zip files.

    Implements many of the features users enjoy from
    :class:`pathlib.Path`.

    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

    >>> path = Path(zf)

    From there, several path operations are available.

    Directory iteration (including the zip file itself):

    >>> a, b = path.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(encoding='utf-8')
    '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.

    >>> str(path)
    'mem/abcde.zip'
    >>> path.name
    'abcde.zip'
    >>> path.filename == pathlib.Path('mem/abcde.zip')
    True
    >>> str(path.parent)
    'mem'

    If the zipfile has no filename, such attributes are not
    valid and accessing them will raise an Exception.

    >>> zf.filename = None
    >>> path.name
    Traceback (most recent call last):
    ...
    TypeError: ...

    >>> path.filename
    Traceback (most recent call last):
    ...
    TypeError: ...

    >>> path.parent
    Traceback (most recent call last):
    ...
    TypeError: ...

    # workaround python/cpython#106763
    >>> pass
    z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})�cCst�|�|_||_dS)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)rRrK�root�at)rr_r`r
r
rr3s

z
Path.__init__cCs(|j|jurtS|j|jf|j|jfkS)zU
        >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
        False
        )r"�NotImplementedr_r`)r�otherr
r
r�__eq__@szPath.__eq__cCst|j|jf�Sr)�hashr_r`r$r
r
r�__hash__Ir&z
Path.__hash__rEN��pwdcOs�|��rt|��|d}|dkr|��st|��|jj|j||d�}d|vr0|s*|r.td��|St|i|��\}}}t	j
||g|�Ri|��S)z�
        Open this entry as text or binary following the semantics
        of ``pathlib.Path.open()`` by passing arguments through
        to io.TextIOWrapper().
        rrErf�bz*encoding args invalid for binary operation)�is_dir�IsADirectoryError�exists�FileNotFoundErrorr_�openr`�
ValueErrorr]�io�
TextIOWrapper)rrHrgrr Zzip_mode�streamr\r
r
rrmLsz	Path.opencCs|jr	t�|j�S|jSr)r`�pathlib�
PurePosixPathr@r$r
r
r�_base`sz
Path._basecC�
|��jSr)rtr=r$r
r
rr=crWz	Path.namecCrur)rt�suffixr$r
r
rrvgrWzPath.suffixcCrur)rt�suffixesr$r
r
rrwkrWz
Path.suffixescCrur)rt�stemr$r
r
rrxorWz	Path.stemcCst�|jj��|j�Sr)rrrr_r@�joinpathr`r$r
r
rr@sr#z
Path.filenamecOsZt|i|��\}}}|jd|g|�Ri|���}|��Wd�S1s&wYdS)NrE)r]rm�read)rrr r\�strmr
r
r�	read_textws$�zPath.read_textcCs6|�d��}|��Wd�S1swYdS)N�rb)rmrz)rr{r
r
r�
read_bytes|s$�zPath.read_bytescCst�|j�d��|j�d�kS�Nr<)rr>r`r)rrr
r
r�	_is_child�szPath._is_childcCs|�|j|�Sr)r"r_)rr`r
r
r�_next��z
Path._nextcCs|jp	|j�d�Sr)r`rCr$r
r
rri�szPath.is_dircCs|��o|��Sr)rkrir$r
r
r�is_file��zPath.is_filecCs|j|j��vSr)r`r_r;r$r
r
rrk�r&zPath.existscCs.|��std��t|j|j���}t|j|�S)NzCan't listdir a file)ri�NotADirectoryErrorr4r�r_r9�filterr�)rZsubsr
r
r�iterdir�szPath.iterdircCst�|j��|�Sr)rrrsr`�match)r�path_patternr
r
rr��r�z
Path.matchcCs"|j�|j�}|jd?}t�|�S)z8
        Return whether this path is a symlink.
        �)r_rAr`Z
external_attr�stat�S_ISLNK)r�inforHr
r
r�
is_symlink�s

zPath.is_symlinkcCsV|s	td|����t�|j�}tdd�}t�||�|��j}t|j	t
||j����S)NzUnacceptable pattern: r<)�seps)
rn�re�escaper`r�compile�	translate�	fullmatchr4r�r�r_r9)r�pattern�prefix�tr�matchesr
r
r�glob�s
z	Path.globcCs|�d|���S)Nz**/)r�)rr�r
r
r�rglob�r&z
Path.rglobcGst�t|�t|j|���Sr)r�relpath�strry)rrb�extrar
r
r�relative_to�szPath.relative_tocCs&t|jjd�}|jrt�||j�S|S)Nz	:zipfile:)rr_r@r`r�join)rr_r
r
r�__str__�szPath.__str__cCs|jj|d�S)Nr$)�_Path__repr�formatr$r
r
r�__repr__�r�z
Path.__repr__cGs&tj|jg|�R�}|�|j�|��Sr)rr�r`r�r_r?)rrb�nextr
r
rry�sz
Path.joinpathcCs6|js|jjSt�|j�d��}|r|d7}|�|�Sr)r`r@�parentrr>rr�)rZ	parent_atr
r
rr��s
zPath.parent)r^)rE)"r)r*r+r,r�rrcrermrt�propertyr=rvrwrxr@r|r~r�r�rir�rkr�r�r�r�r�r�r�r�ry�__truediv__r�r
r
r
rr�sJf

	




	r)r,rYror	rrrr�r�rD�
_functoolsrrZcompat.py310rr�r�__all__rr�dict�fromkeysr5rrrGr.rRr]rr
r
r
r�<module>s.	K