Viewing File: /opt/hc_python/lib/python3.12/site-packages/zipp/__pycache__/__init__.cpython-312.pyc

�

^��g!.���dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZdgZd�Zd	�Zej(Z	d
�ZGd�d�ZGd
�dee	j0�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�)�
text_encoding)�
Translator)�save_method_args�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 �</opt/hc_python/lib/python3.12/site-packages/zipp/__init__.py�_parentsrs�� ���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  r
rr0sS����*�;�;�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
�_differencerOs!��
� � ��Z��!=�!=�w�G�Grc�<��eZdZdZe�fd��Zd�Z�fd�Z�xZS)�InitializedStatez?
    Mix-in to save the initialization state for pickling.
    c�$��t�|�|i|��y�N��super�__init__)�self�args�kwargs�	__class__s   �r
r#zInitializedState.__init__\s���
���$�)�&�)rc�Z�|jj|jjfSr )�_saved___init__r%r&�r$s r
�__getstate__zInitializedState.__getstate__`s%���#�#�(�(�$�*>�*>�*E�*E�E�Erc�.��|\}}t�|�|i|��yr r!)r$�stater%r&r's    �r
�__setstate__zInitializedState.__setstate__cs������f�
���$�)�&�)r)	�__name__�
__module__�__qualname__�__doc__rr#r+r.�
__classcell__�r's@r
rrWs,�����*��*�F�*�*rrc���eZdZdZed��Z�fd�Zd�Zd�Z�fd�Z	e
d��Ze
dejd	ejfd
��Z�xZS)�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>vs����6�g��1�y�}�}�$�g�s�)r	�chain�
from_iterable�mapr�_deduper)�names�parents�as_dirss   r
�
_implied_dirszCompleteDirs._implied_dirsss9���/�/�/�/��H�e�0D�E��6�g�6���{�7�E�2�3�3rc�Z��t�|��}|t|j|��zSr )r"�namelist�listrC)r$r@r's  �r
rEzCompleteDirs.namelistys+����� �"���t�D�.�.�u�5�6�6�6rc�4�t|j��Sr )rrEr*s r
�	_name_setzCompleteDirs._name_set}s���4�=�=�?�#�#rc�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).
        �/)rH)r$�namer@�dirname�	dir_matchs     r
�resolve_dirzCompleteDirs.resolve_dir�s:��
��� ����*����%�:�'�U�*:�	�#�w�-��-rc���	t�|�|�S#t$r=|jd�r||j	�vr�tj|��cYSwxYw)z6
        Supplement getinfo for implied dirs.
        rJ)�filename)r"�getinfo�KeyError�endswithrH�zipfile�ZipInfo)r$rKr's  �r
rQzCompleteDirs.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)�
isinstancer6rT�ZipFile�moder')�cls�sources  r
�makezCompleteDirs.make�sK���f�l�+��M��&�'�/�/�2��v�;���f�k�k�!��C�����
r�zf�returnc�r�|j|j��D]}|j|d��|S)z�
        Given a writable zip file zf, inject directory entries for
        any directories implied by the presence of children.
        r)rCrE�writestr)r[r^rKs   r
�injectzCompleteDirs.inject�s2���%�%�b�k�k�m�4�D��K�K��c�"�5��	r)r/r0r1r2�staticmethodrCrErHrNrQ�classmethodr]rTrYrbr3r4s@r
r6r6hsn�����4��4�
7�$�.�	2�����$������G�O�O���rr6c�t��eZdZdZd�Zej�fd��Zd�Zej�fd��Z	�xZ
S)�
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    c��|jSr )�	_namelistr*s r
rEzFastLookup.namelist�s���~�~�rc� ��t�|��Sr )r"rE�r$r's �r
rhzFastLookup._namelist�s����w��!�!rc��|jSr )�_name_set_propr*s r
rHzFastLookup._name_set�s���"�"�"rc� ��t�|��Sr )r"rHrjs �r
rlzFastLookup._name_set_prop�s����w� �"�"r)r/r0r1r2rE�	functools�cached_propertyrhrHrlr3r4s@r
rfrf�sF����
����"��"�#����#��#rrfc�d�tjjdk(}d|z}t||�||fS)N�pypy�)�sys�implementationrKr)�encodingr%r&�is_pypy�stack_levels     r
�_extract_text_encodingrx�s5��� � �%�%��/�G��g�+�K���;�/��v�=�=rc��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 :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})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)rfr]�root�at)r$r{r|s   r
r#z
Path.__init__8s���O�O�D�)��	���rc��|j|jurtS|j|jf|j|jfk(S)zU
        >>> Path(zipfile.ZipFile(io.BytesIO(), 'w')) == 'foo'
        False
        )r'�NotImplementedr{r|)r$�others  r
�__eq__zPath.__eq__Es?��
�>�>����0�!�!��	�	�4�7�7�#��
�
�E�H�H�'=�=�=rc�D�t|j|jf�Sr )�hashr{r|r*s r
�__hash__z
Path.__hash__Ns���T�Y�Y����(�)�)rN��pwdc�N�|j�rt|��|d}|dk(r|j�st|��|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().
        rrWr��bz*encoding args invalid for binary operation)�is_dir�IsADirectoryError�exists�FileNotFoundErrorr{�openr|�
ValueErrorrx�io�
TextIOWrapper)r$rZr�r%r&�zip_mode�streamrus        r
r�z	Path.openQs����;�;�=�#�D�)�)���7���s�?�4�;�;�=�#�D�)�)����������s��;���$�;��v� �!M�N�N��M�!7��!H��!H���$�������B�4�B�6�B�Brc�p�tj|jxs|jj�Sr )�pathlib�
PurePosixPathr|r{rPr*s r
�_basez
Path._basees&���$�$�T�W�W�%B��	�	�0B�0B�C�Crc�6�|j�jSr )r�rKr*s r
rKz	Path.nameh����z�z�|� � � rc�6�|j�jSr )r��suffixr*s r
r�zPath.suffixls���z�z�|�"�"�"rc�6�|j�jSr )r��suffixesr*s r
r�z
Path.suffixesps���z�z�|�$�$�$rc�6�|j�jSr )r��stemr*s r
r�z	Path.stemtr�rc��tj|jj�j	|j
�Sr )r�rr{rP�joinpathr|r*s r
rPz
Path.filenamexs*���|�|�D�I�I�.�.�/�8�8����A�Arc��t|i|��\}}}|jd|g|��i|��5}|j�cddd�S#1swYyxYw)NrW)rxr��read)r$r%r&ru�strms     r
�	read_textzPath.read_text|sI��!7��!H��!H���$��
�T�Y�Y�s�H�
6�t�
6�v�
6�$��9�9�;�7�
6�
6�s�A�A
c�p�|jd�5}|j�cddd�S#1swYyxYw)N�rb)r�r�)r$r�s  r
�
read_byteszPath.read_bytes�s"��
�Y�Y�t�_���9�9�;��_�_�s�,�5c��tj|jjd��|jjd�k(S�NrJ)rrLr|r)r$rs  r
�	_is_childzPath._is_child�s2��� � �������!4�5�������9L�L�Lrc�:�|j|j|�Sr )r'r{)r$r|s  r
�_nextz
Path._next�s���~�~�d�i�i��,�,rc�V�|jxs|jjd�Sr�)r|rSr*s r
r�zPath.is_dir�s"���7�7�{�3�d�g�g�.�.�s�3�3rc�H�|j�xr|j�Sr )r�r�r*s r
�is_filezPath.is_file�s���{�{�}�2�T�[�[�]�!2�2rc�N�|j|jj�vSr )r|r{rHr*s r
r�zPath.exists�s���w�w�$�)�)�-�-�/�/�/rc��|j�std��t|j|jj��}t
|j|�S)NzCan't listdir a file)r�r�r>r�r{rE�filterr�)r$�subss  r
�iterdirzPath.iterdir�sE���{�{�}��3�4�4��4�:�:�t�y�y�1�1�3�4���d�n�n�d�+�+rc�^�tj|j�j|�Sr )r�r�r|�match)r$�path_patterns  r
r�z
Path.match�s"���$�$�T�W�W�-�3�3�L�A�Arc��|jj|j�}|jdz	}t	j
|�S)z8
        Return whether this path is a symlink.
        �)r{rQr|�
external_attr�stat�S_ISLNK)r$�inforZs   r
�
is_symlinkzPath.is_symlink�s;���y�y� � ����)���!�!�R�'���|�|�D�!�!rc�J�|std|����tj|j�}t	d��}tj
||j
|�z�j}t|jt||jj���S)NzUnacceptable pattern: rJ)�seps)
r��re�escaper|r�compile�	translate�	fullmatchr>r�r�r{rE)r$�pattern�prefix�tr�matchess     r
�globz	Path.glob�s{����5�g�[�A�B�B����4�7�7�#��
�S�
!���*�*�V�b�l�l�7�&;�;�<�F�F���4�:�:�v�g�t�y�y�/A�/A�/C�D�E�Erc�*�|jd|���S)Nz**/)r�)r$r�s  r
�rglobz
Path.rglob�s���y�y�3�w�i��)�)rc�l�tjt|�t|j|���Sr )r�relpath�strr�)r$r�extras   r
�relative_tozPath.relative_to�s)��� � ��T��C������0F�,G�H�Hrc�j�tj|jj|j�Sr )r�joinr{rPr|r*s r
�__str__zPath.__str__�s!���~�~�d�i�i�0�0�$�'�'�:�:rc�:�|jj|��S)Nr*)�_Path__repr�formatr*s r
�__repr__z
Path.__repr__�s���{�{�!�!�t�!�,�,rc��tj|jg|���}|j|jj|��Sr )rr�r|r�r{rN)r$r�nexts   r
r�z
Path.joinpath�s7���~�~�d�g�g�.��.���z�z�$�)�)�/�/��5�6�6rc���|js|jjStj|jjd��}|r|dz
}|j
|�Sr�)r|rP�parentrrLrr�)r$�	parent_ats  r
r�zPath.parent�sR���w�w��=�=�'�'�'��%�%�d�g�g�n�n�S�&9�:�	�����I��z�z�)�$�$r)�)rW)"r/r0r1r2r�r#r�r�r�r��propertyrKr�r�r�rPr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��__truediv__r��rr
rr�s��d�LN�F��>�*�C��C�(D��!��!��#��#��%��%��!��!��B��B��
�M�-�4�3�0�,�B�"�F�*�I�;�-�7��K�
�%��%rr )r2rnr�r	r�rr�r�rsrT�compat.py310rr�r�
_functoolsr�__all__rr�dict�fromkeysr?rrrYr6rfrxrr�rr
�<module>r�s�����	����	��
��'��(��(��6�&+�6�-�-��/�H�*�*�"H�#�W�_�_�H�V#��#�*>�x%�x%r
Back to Directory File Manager