%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/zipfile/_path/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/zipfile/_path/__pycache__/__init__.cpython-312.pyc

�

���f*����dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	dgZ
d�Zd�Ze
jZ	d�ZGd	�d
�ZGd�deej$�ZGd
�de�Zdd�ZGd�d�Zy)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�)�	translate�Pathc�B�tjt|�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)�paths �-/usr/lib/python3.12/zipfile/_path/__init__.py�_parentsrs�� ���I�d�O�Q��5�5�c#�K�|jtj�}|jtj�r=|��tj|�\}}|jtj�r�<yy�w)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
�tails  rr	r	+sS����*�;�;�y�}�}�%�D�
�+�+�i�m�m�
$��
��_�_�T�*�
��d��+�+�i�m�m�
$�s�A:A?�=A?c�T�tjt|�j|�S)zZ
    Return items in minuend not in subtrahend, retaining order
    with O(1) lookup.
    )r�filterfalse�set�__contains__)�minuend�
subtrahends  r�_differencerJs!��
� � ��Z��!=�!=�w�G�Gr
c�2��eZdZdZ�fd�Zd�Z�fd�Z�xZS)�InitializedStatez?
    Mix-in to save the initialization state for pickling.
    c�@��||_||_t�|�|i|��y�N)�_InitializedState__args�_InitializedState__kwargs�super�__init__)�self�args�kwargs�	__class__s   �rr"zInitializedState.__init__Ws#��������
�
���$�)�&�)r
c�2�|j|jfSr)rr �r#s r�__getstate__zInitializedState.__getstate__\s���{�{�D�M�M�)�)r
c�.��|\}}t�|�|i|��yr)r!r")r#�stater$r%r&s    �r�__setstate__zInitializedState.__setstate___s������f�
���$�)�&�)r
)�__name__�
__module__�__qualname__�__doc__r"r)r,�
__classcell__�r&s@rrrRs����*�
*�*�*r
rc�X��eZdZdZed��Z�fd�Zd�Zd�Z�fd�Z	e
d��Z�xZS)�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/']
    c��tjjtt|��}d�|D�}tt
||��S)Nc3�BK�|]}|tjz���y�wr)rr)�.0�ps  r�	<genexpr>z-CompleteDirs._implied_dirs.<locals>.<genexpr>rs����6��1�y�}�}�$�6�s�)r�chain�
from_iterable�mapr�_deduper)�names�parents�as_dirss   r�
_implied_dirszCompleteDirs._implied_dirsos9���/�/�/�/��H�e�0D�E��6�g�6���{�7�E�2�3�3r
c�Z��t�|��}|t|j|��zSr)r!�namelist�listrA)r#r>r&s  �rrCzCompleteDirs.namelistus+����� �"���t�D�.�.�u�5�6�6�6r
c�4�t|j��Sr)rrCr(s r�	_name_setzCompleteDirs._name_setys���4�=�=�?�#�#r
c�L�|j�}|dz}||vxr||v}|r|S|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_dirzCompleteDirs.resolve_dir|s:��
��� ����*����%�:�'�U�*:�	�#�w�-��-r
c���	t�|�|�S#t$r=|jd�r||j	�vr�tj|��cYSwxYw)z6
        Supplement getinfo for implied dirs.
        rH)�filename)r!�getinfo�KeyError�endswithrF�zipfile�ZipInfo)r#rIr&s  �rrOzCompleteDirs.getinfo�sR���	2��7�?�4�(�(���	2��=�=��%��T�^�^�5E�)E���?�?�D�1�1�	2�s��AA�Ac��t|t�r|St|tj�s||�Sd|jvrt}||_|S)zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        �r)�
isinstancer4rR�ZipFile�moder&)�cls�sources  r�makezCompleteDirs.make�sK���f�l�+��M��&�'�/�/�2��v�;���f�k�k�!��C�����
r
)
r-r.r/r0�staticmethodrArCrFrLrO�classmethodr[r1r2s@rr4r4dsD�����4��4�
7�$�.�	2����r
r4c�,��eZdZdZ�fd�Z�fd�Z�xZS)�
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    c���tjt�5|jcddd�S#1swYnxYwt�|��|_|jSr)�
contextlib�suppress�AttributeError�_FastLookup__namesr!rC�r#r&s �rrCzFastLookup.namelist�sF���
�
 �
 ��
0�	 ��<�<�	 �	 �	 ���w�'�)����|�|���1�:c���tjt�5|jcddd�S#1swYnxYwt�|��|_|jSr)rarbrc�_FastLookup__lookupr!rFres �rrFzFastLookup._name_set�sF���
�
 �
 ��
0�	!��=�=�	!�	!�	!����)�+��
��}�}�rf)r-r.r/r0rCrFr1r2s@rr_r_�s����
��r
r_c�4�tj|d�||fS)N�)�io�
text_encoding)�encodingr$r%s   r�_extract_text_encodingrn�s��
���H�a�(�$��6�6r
c��eZdZdZdZd d�Zd�Zd�Zd!dd�d�Zd	�Z	e
d
��Ze
d��Ze
d��Z
e
d
��Ze
d��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZeZ e
d��Z!y)"ru<
    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(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(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. 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�F�tj|�|_||_y)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)r_r[�root�at)r#rqrrs   rr"z
Path.__init__
s���O�O�D�)��	���r
c��|j|jurtS|j|jf|j|jfk(S)zU
        >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
        False
        )r&�NotImplementedrqrr)r#�others  r�__eq__zPath.__eq__s?��
�>�>����0�!�!��	�	�4�7�7�#��
�
�E�H�H�'=�=�=r
c�D�t|j|jf�Sr)�hashrqrrr(s r�__hash__z
Path.__hash__#s���T�Y�Y����(�)�)r
N��pwdc�N�|j�rt|��|d}|j�s|dk(rt|��|jj|j||��}d|vr|s|rtd��|St|i|��\}}}tj||g|��i|��S)z�
        Open this entry as text or binary following the semantics
        of ``pathlib.Path.open()`` by passing arguments through
        to io.TextIOWrapper().
        rrUrz�bz*encoding args invalid for binary operation)�is_dir�IsADirectoryError�exists�FileNotFoundErrorrq�openrr�
ValueErrorrnrk�
TextIOWrapper)r#rXr{r$r%�zip_mode�streamrms        rr�z	Path.open&s����;�;�=�#�D�)�)���7���{�{�}��S��#�D�)�)����������s��;���$�;��v� �!M�N�N��M�!7��!H��!H���$�������B�4�B�6�B�Br
c�p�tj|jxs|jj�Sr)�pathlib�
PurePosixPathrrrqrNr(s r�_basez
Path._base:s&���$�$�T�W�W�%B��	�	�0B�0B�C�Cr
c�6�|j�jSr)r�rIr(s rrIz	Path.name=����z�z�|� � � r
c�6�|j�jSr)r��suffixr(s rr�zPath.suffixAs���z�z�|�"�"�"r
c�6�|j�jSr)r��suffixesr(s rr�z
Path.suffixesEs���z�z�|�$�$�$r
c�6�|j�jSr)r��stemr(s rr�z	Path.stemIr�r
c��tj|jj�j	|j
�Sr)r�rrqrN�joinpathrrr(s rrNz
Path.filenameMs*���|�|�D�I�I�.�.�/�8�8����A�Ar
c��t|i|��\}}}|jd|g|��i|��5}|j�cddd�S#1swYyxYw)NrU)rnr��read)r#r$r%rm�strms     r�	read_textzPath.read_textQsR��!7��!H��!H���$��
�T�Y�Y�s�H�
6�t�
6�v�
6�	�$��9�9�;�	�	�	�s�A�A
c�p�|jd�5}|j�cddd�S#1swYyxYw)N�rb)r�r�)r#r�s  r�
read_byteszPath.read_bytesVs-��
�Y�Y�t�_�	���9�9�;�	�	�	�s�,�5c��tj|jjd��|jjd�k(S�NrH)rrJrrr)r#r
s  r�	_is_childzPath._is_childZs2��� � �������!4�5�������9L�L�Lr
c�:�|j|j|�Sr)r&rq)r#rrs  r�_nextz
Path._next]s���~�~�d�i�i��,�,r
c�V�|jxs|jjd�Sr�)rrrQr(s rr~zPath.is_dir`s"���7�7�{�3�d�g�g�.�.�s�3�3r
c�H�|j�xr|j�Sr)r�r~r(s r�is_filezPath.is_filecs���{�{�}�2�T�[�[�]�!2�2r
c�N�|j|jj�vSr)rrrqrFr(s rr�zPath.existsfs���w�w�$�)�)�-�-�/�/�/r
c��|j�std��t|j|jj��}t
|j|�S)NzCan't listdir a file)r~r�r<r�rqrC�filterr�)r#�subss  r�iterdirzPath.iterdirisE���{�{�}��3�4�4��4�:�:�t�y�y�1�1�3�4���d�n�n�d�+�+r
c�^�tj|j�j|�Sr)r�r�rr�match)r#�path_patterns  rr�z
Path.matchos"���$�$�T�W�W�-�3�3�L�A�Ar
c��y)z]
        Return whether this path is a symlink. Always false (python/cpython#82102).
        F�r(s r�
is_symlinkzPath.is_symlinkrs��r
c�&�|std|����tj|j�}tj|t|�z�j}t|jt||jj���S)NzUnacceptable pattern: )r��re�escaperr�compiler�	fullmatchr<r�r�rqrC)r#�pattern�prefix�matchess    r�globz	Path.globxsm����5�g�[�A�B�B����4�7�7�#���*�*�V�i��&8�8�9�C�C���4�:�:�v�g�t�y�y�/A�/A�/C�D�E�Er
c�*�|jd|���S)Nz**/)r�)r#r�s  r�rglobz
Path.rglob�s���y�y�3�w�i��)�)r
c�l�tjt|�t|j|���Sr)r�relpath�strr�)r#ru�extras   r�relative_tozPath.relative_to�s)��� � ��T��C������0F�,G�H�Hr
c�j�tj|jj|j�Sr)r�joinrqrNrrr(s r�__str__zPath.__str__�s!���~�~�d�i�i�0�0�$�'�'�:�:r
c�:�|jj|��S)Nr()�_Path__repr�formatr(s r�__repr__z
Path.__repr__�s���{�{�!�!�t�!�,�,r
c��tj|jg|���}|j|jj|��Sr)rr�rrr�rqrL)r#ru�nexts   rr�z
Path.joinpath�s7���~�~�d�g�g�.��.���z�z�$�)�)�/�/��5�6�6r
c���|js|jjStj|jjd��}|r|dz
}|j
|�Sr�)rrrN�parentrrJrr�)r#�	parent_ats  rr�zPath.parent�sR���w�w��=�=�'�'�'��%�%�d�g�g�n�n�S�&9�:�	�����I��z�z�)�$�$r
)�)rU)"r-r.r/r0r�r"rvryr�r��propertyrIr�r�r�rNr�r�r�r�r~r�r�r�r�r�r�r�r�r�r�r��__truediv__r�r�r
rrr�s��K�ZN�F��>�*�C��C�(D��!��!��#��#��%��%��!��!��B��B��
�M�-�4�3�0�,�B��F�*�I�;�-�7��K�
�%��%r
r)r0rkrrRrrar�r�r�r�__all__rr	�dict�fromkeysr=rrrWr4r_rnrr�r
r�<module>r�s����
������	���(��6�&+�6�-�-��/�H�*�*�$>�#�W�_�_�>�B���&7�
\%�\%r

Zerion Mini Shell 1.0