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

�

_��g���&�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
ddlmZmZeej"efZeZd�Zeddeedefd��Zd	ej"deefd
�Zej0deedej"fd��Zej4dedej"fd
��Zej4dddej"fd��Zd�Zd	ej"fd�Zej<	dej>d�d��Z d�Z!dede"fd�Z#ej0d��Z$e$j5ejJ�ej<d���Zej<dejLfd��Z'ej<d��Z(d�Z)y)�N)�Optional�Union�cast�)�ResourceReader�Traversablec�`���t��tj����f��fd�	�}|S)a1
    Replace 'package' parameter as 'anchor' and warn about the change.

    Other errors should fall through.

    >>> files('a', 'b')
    Traceback (most recent call last):
    TypeError: files() takes from 0 to 1 positional arguments but 2 were given

    Remove this compatibility in Python 3.14.
    c���|�ur1|�ur	�||�Stjdtd���|�S|�ur��S�|�S)Nz/First parameter to files is renamed to 'anchor'�)�
stacklevel)�warnings�warn�DeprecationWarning)�anchor�package�func�	undefineds  ���J/opt/hc_python/lib/python3.12/site-packages/importlib_resources/_common.py�wrapperz"package_to_anchor.<locals>.wrapper!sZ����)�#��Y�&��F�G�,�,��M�M�A�"��
�
��=� �
�y�
 ��6�M��F�|��)�object�	functools�wraps)rrrs` @r�package_to_anchorrs3�����I��_�_�T�� �)�����Nrr�returnc�*�tt|��S)z3
    Get a Traversable resource for an anchor.
    )�from_package�resolve)rs r�filesr3s��
����(�(rrc�r�|j}t|jdd�}|�y||j�S)z?
    Return the package's loader if it's a ResourceReader.
    �get_resource_readerN)�__spec__�getattr�loader�name)r�spec�readers   rr!r!;s9�����D�
�T�[�[�"7��
>�F�
�~���$�)�)��r�candc�6�ttj|�S�N)r�types�
ModuleType�r(s rrrKs���� � �$�'�'rc�,�tj|�Sr*)�	importlib�
import_moduler-s r�_r1Ps���"�"�4�(�(rc�B�tt�jd�S)N�__name__)r�
_infer_caller�	f_globalsr-s rr1r1Us���=�?�,�,�Z�8�9�9rc����fd�}d�}tj��tj|��}tj||�}t	|�j
S)zS
    Walk the stack and find the frame of the first caller not in this module.
    c�<��|j�djk(S)Nr)�filename)�
frame_info�stacks �r�is_this_filez#_infer_caller.<locals>.is_this_file_s����"�"�e�A�h�&7�&7�7�7rc� �|jdk(S)Nr)�function)r9s r�
is_wrapperz!_infer_caller.<locals>.is_wrapperbs���"�"�i�/�/r)�inspectr:�	itertools�filterfalse�next�frame)r;r>�
not_this_file�callersr:s    @rr4r4ZsN���
8�0�
�M�M�O�E��)�)�,��>�M��#�#�J�
�>�G���=���rc��ddlm}||�}|jj|j�}|j�S)z=
    Return a Traversable object for the given package.

    r)�	wrap_spec)�future.adaptersrGr$r!r%r)rrGr&r's    rrrls5��+��W��D�
�[�[�
,�
,�T�Y�Y�
7�F��<�<�>�r)�
_os_removec#�pK�tj|��\}}		tj||��tj|�~tj|���	||�y#tj|�wxYw#t$rYywxYw#	||�w#t$rYwwxYwxYw�w�N)�suffix)�tempfile�mkstemp�os�write�close�pathlib�Path�FileNotFoundError)r'rLrI�fd�raw_paths     r�	_tempfilerWys������#�#�6�2�L�B���	��H�H�R���"��H�H�R�L���l�l�8�$�$�	��x� ��
�H�H�R�L��!�	��	��	��x� �� �	��	�so�B6�A0�-B�'B
�/B6�0B�B�
	B�B6�B�B6�B3�B$�#B3�$	B0�-B3�/B0�0B3�3B6c�D�t|j|j��SrK)rW�
read_bytesr%��paths r�
_temp_filer\�s���T�_�_�T�Y�Y�7�7rr[c��tjt�5|j�cddd�S#1swYyxYw)a
    Some Traversables implement ``is_dir()`` to raise an
    exception (i.e. ``FileNotFoundError``) when the
    directory doesn't exist. This function wraps that call
    to always return a boolean and only return True
    if there's a dir and it exists.
    NF)�
contextlib�suppressrT�is_dirrZs r�_is_present_dirra�s+��
�	�	�.�	/��{�{�}�
0�	/�	/��s�4�=c�D�t|�rt|�St|�S)zu
    Given a Traversable object, return that object as a
    path on the local file system in a context manager.
    )ra�	_temp_dirr\rZs r�as_filerd�s��.�d�3�9�T�?�I��D�9I�Irc#�K�|��y�w)z7
    Degenerate behavior for pathlib.Path objects.
    N�rZs rr1r1�s
�����J�s��dirc#�hK�|5}tj|���ddd�y#1swYyxYw�w)zF
    Wrap tempfile.TemporaryDirectory to return a pathlib object.
    N)rRrS)rg�results  r�
_temp_pathrj�s%����


���l�l�6�"�"�

���s�2�&�	2�/�2c#�K�|j�sJ�ttj��5}t	||���ddd�y#1swYyxYw�w)zt
    Given a traversable dir, recursively replicate the whole tree
    to the file system in a context manager.
    N)r`rjrM�TemporaryDirectory�_write_contents)r[�temp_dirs  rrcrc�sA�����;�;�=��=�	�H�/�/�1�	2�h��h��-�-�
3�	2�	2�s�0A�A
�	A�
A�Ac��|j|j�}|j�r3|j�|j	�D]}t||��|S|j
|j��|Sr*)�joinpathr%r`�mkdir�iterdirrm�write_bytesrY)�target�source�child�items    rrmrm�sf���O�O�F�K�K�(�E�
�}�}��
���
��N�N�$�D��E�4�(�%��L�	���&�+�+�-�.��Lrr*)�)*r^rr/r?r@rOrRrMr+r
�typingrrr�abcrrr,�str�Package�Anchorrrr!�singledispatchr�registerr1r4r�contextmanager�removerWr\�boolrardrSrlrjrcrmrfrr�<module>r�s�������	�����(�(�,�
�� � �#�%�
&��	���@�)�(�6�"�)�k�)��)�
��!1�!1�
�h�~�6N�
� ���(�(�6�"�(�u�'7�'7�(��(�	���)�C�)�E�$�$�)��)�	���:�D�:�U�%�%�:��:��$
�%�*�*�
�������y�y�
���48�
�+�
�$�
����J��J�	���'�,�,������� �����#�H�/�/�#��#����.��.�r
Back to Directory File Manager