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

�

`�*jj��,�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZd�ZGd	�d
ej$�ZGd�dej$�ZGd
�dej*�ZGd�dej$�Zd�Zy)�)�annotationsN)�Iterator�)�abc)�only)�ZipPathc�R�ttjj|��S�N)�iter�collections�OrderedDict�fromkeys)�itemss �J/opt/hc_python/lib/python3.12/site-packages/importlib_resources/readers.py�remove_duplicatesrs����'�'�0�0��7�8�8�c��eZdZd�Zd�Zd�Zy)�
FileReaderc�`�tj|j�j|_yr
)�pathlib�Path�path�parent)�self�loaders  r�__init__zFileReader.__init__s���L�L����-�4�4��	rc�J�t|jj|��S�z{
        Return the file system path to prevent
        `resources.path()` from creating a temporary
        copy.
        ��strr�joinpath�r�resources  r�
resource_pathzFileReader.resource_path����4�9�9�%�%�h�/�0�0rc��|jSr
�r�rs r�fileszFileReader.files!����y�y�rN)�__name__�
__module__�__qualname__rr$r)�rrrrs��5�1�rrc�0��eZdZd�Z�fd�Zd�Zd�Z�xZS)�	ZipReaderc���|jjdd�|_|j|�r-|jd�\}}}|xj|dzz
c_|j|_y)N�\�/�.)�prefix�replace�
is_package�
rpartition�archive)rr�module�_�names     rrzZipReader.__init__&s[���m�m�+�+�D�#�6������V�$��*�*�3�/�J�A�q�$��K�K�4�#�:�%�K��~�~��rc�v��	t�|�|�S#t$r}t|jd��d}~wwxYw�Nr)�super�
open_resource�KeyError�FileNotFoundError�args)rr#�exc�	__class__s   �rr@zZipReader.open_resource-s;���	1��7�(��2�2���	1�#�C�H�H�Q�K�0�0��	1�s��	8�3�8c��|j�j|�}|j�xr|j�S)zf
        Workaround for `zipfile.Path.is_file` returning true
        for non-existent paths.
        )r)r!�is_file�exists)rr�targets   r�is_resourcezZipReader.is_resource3s2��
����&�&�t�,���~�~��3�F�M�M�O�3rc�B�t|j|j�Sr
)rr9r5r(s rr)zZipReader.files;s���t�|�|�T�[�[�1�1r)r+r,r-rr@rJr)�
__classcell__�rEs@rr0r0%s���&�1�4�2rr0c�r��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	�fd�Z
ed	��Zd
�Z
ed��Zd�Z�xZS)
�MultiplexedPathz�
    Given a series of Traversable objects, implement a merged
    version of the interface across all objects. Useful for
    namespace packages which may be multihomed at a single
    name.
    c���tttt|���|_|js
d}t|��t
d�|jD��std��y)Nz.MultiplexedPath must contain at least one pathc3�<K�|]}|j����y�wr
��is_dir��.0rs  r�	<genexpr>z+MultiplexedPath.__init__.<locals>.<genexpr>Ls����9�[�T�4�;�;�=�[�s�z)MultiplexedPath only supports directories)�list�map�_ensure_traversabler�_pathsrB�all�NotADirectoryError)r�paths�messages   rrzMultiplexedPath.__init__GsV���3�2�4E�e�4L�M�N����{�{�F�G�#�G�,�,��9�T�[�[�9�9�$�%P�Q�Q�:rc���d�|jD�}tjd�}tjt||��|��}t
|jd�|D��S)Nc3�JK�|]}|j�D]}|����y�wr
)�iterdir)rUr�childs   rrVz*MultiplexedPath.iterdir.<locals>.<genexpr>Ps����N�k�d�t�|�|�~�e�E�~�E�k�s�!#r<)�keyc3�&K�|]	\}}|���y�wr
r.)rUr<�locss   rrVz*MultiplexedPath.iterdir.<locals>.<genexpr>Ss����!@��:�4��$��s�)rZ�operator�
attrgetter�	itertools�groupby�sortedrX�_follow)r�children�by_name�groupss    rrazMultiplexedPath.iterdirOsP��N�d�k�k�N���%�%�f�-���"�"�6�(��#@�g�N���4�<�<�!@��!@�A�Arc��t|�d����Nz is not a file�rBr(s r�
read_byteszMultiplexedPath.read_bytesU����4�&�� 7�8�8rc��t|�d���rprq�rrC�kwargss   r�	read_textzMultiplexedPath.read_textXrsrc��y)NTr.r(s rrSzMultiplexedPath.is_dir[s��rc��y)NFr.r(s rrGzMultiplexedPath.is_file^s��rc���	t�|�|�S#tj$r|jdj|�cYSwxYwr>)r?r!r�TraversalErrorrZ)r�descendantsrEs  �rr!zMultiplexedPath.joinpathasJ���	9��7�#�[�1�1���!�!�	9�+�4�;�;�q�>�*�*�K�8�8�	9�s��/A�Ac��tj|d�\}}}	t|�S#t$r%	||�cYS#t$rt|�cYcYSwxYwwxYw)z�
        Construct a MultiplexedPath if needed.

        If children contains a sole element, return it.
        Otherwise, return a MultiplexedPath of the items.
        Unless one of the items is not a Directory, then return the first.
        �)rh�teer�
ValueErrorr\�next)�clsrl�subdirs�one_dir�one_files     rrkzMultiplexedPath._followisa��&/�]�]�8�Q�%?�"���(�	&���=� ���	&�
&��G�}�$��%�
&��H�~�%�
&��	&�s)�
'�	A�8�A�A�A�A�Ac��t|�d���rprqrus   r�openzMultiplexedPath.open|rsrc�4�|jdjSr>)rZr<r(s rr<zMultiplexedPath.names���{�{�1�~�"�"�"rc�R�djd�|jD��}d|�d�S)Nz, c3�(K�|]
}d|�d����y�w)�'Nr.rTs  rrVz+MultiplexedPath.__repr__.<locals>.<genexpr>�s����>�+�$�A�d�V�1�+�+�s�zMultiplexedPath(�))�joinrZ)rr]s  r�__repr__zMultiplexedPath.__repr__�s)���	�	�>�$�+�+�>�>��!�%���*�*r)r+r,r-�__doc__rrarrrwrSrGr!�classmethodrkr��propertyr<r�rLrMs@rrOrO?s_����R�B�9�9���9��&��&�$9��#��#�+rrOc�T�eZdZd�Zedd��Zed	d��Zed
d��Zd�Z	d�Z
y)�NamespaceReaderc	��dt|�vrtd��tttt|j|���|_y)N�
NamespacePathzInvalid path)r r�rO�filter�boolrX�_resolver)r�namespace_paths  rrzNamespaceReader.__init__�s8���#�n�"5�5��^�,�,�#�V�D�#�d�m�m�^�2T�%U�V��	rc�J�d�|j|�D�}t|d�S)a�
        Given an item from a namespace path, resolve it to a Traversable.

        path_str might be a directory on the filesystem or a path to a
        zipfile plus the path within the zipfile, e.g. ``/foo/bar`` or
        ``/foo/baz.zip/inner_dir`` or ``foo\baz.zip\inner_dir\sub``.

        path_str might also be a sentinel used by editable packages to
        trigger other behaviors (see python/importlib_resources#311).
        In that case, return None.
        c3�BK�|]}|j�s�|���y�wr
rR)rU�cands  rrVz+NamespaceReader._resolve.<locals>.<genexpr>�s����Q�!?��4�;�;�=��!?�s��N)�_candidate_pathsr�)r��path_str�dirss   rr�zNamespaceReader._resolve�s'��R��!5�!5�h�!?�Q���D�$��rc#�pK�tj|���|j|�Ed{���y7��wr
)rr�_resolve_zip_path)r�r�s  rr�z NamespaceReader._candidate_paths�s)�����l�l�8�$�$��(�(��2�2�2�s�,6�4�6c#�K�tttjd|���D]�}t	j
tttt�5||j�djdd�dz}t|d|j�|jd����ddd���y#1swY��xYw�w)Nz[\\/]r2r3)�reversedrW�re�finditer�
contextlib�suppressrB�IsADirectoryErrorr\�PermissionError�endr6r�start�lstrip)r��match�inners   rr�z!NamespaceReader._resolve_zip_path�s������d�2�;�;�x��#B�C�D�E��$�$�!�!�"��	�!������/�7�7��c�B�S�H���h������7����c�9J�K�K���E���s�AC�AB6�+C�6B?	�;Cc�J�t|jj|��Srrr"s  rr$zNamespaceReader.resource_path�r%rc��|jSr
r'r(s rr)zNamespaceReader.files�r*rN)�returnzabc.Traversable | None)r�r r�zIterator[abc.Traversable])r�r )r+r,r-rr�r�r��staticmethodr�r$r)r.rrr�r��sP��W�
�
 ��
 ��3��3��	L��	L�1�rr�c��t|t�s|Stjdtd��tj|�S)zk
    Convert deprecated string arguments to traversables (pathlib.Path).

    Remove with Python 3.15.
    z<String arguments are deprecated. Pass a Traversable instead.r~)�
stacklevel)�
isinstancer �warnings�warn�DeprecationWarningrrr's rrYrY�s9���d�C� ����M�M�F�����<�<���r)�
__future__rrr�rhrfrr�r��collections.abcr�r�
_itertoolsr�compat.py39rr�TraversableResourcesrr0�TraversablerOr�rYr.rr�<module>r�s}��"������	��$��� �9�
��)�)�
� 2��(�(�2�4F+�c�o�o�F+�R0�c�.�.�0�fr
Back to Directory File Manager