� !A?h����ddlmZddlmZddlmZGd�d��ZGd�d��Zdd �ZGd �d ��Z d �Z dS)�)�suppress)� TextIOWrapper�)�abcc�$�eZdZdZd�fd�Zd�ZdS)�SpecLoaderAdapterz> Adapt a package spec to adapt the underlying loader. c��|jS�N)�loader��specs �J/opt/alt/python-internal/lib64/python3.11/importlib/resources/_adapters.py�zSpecLoaderAdapter. s��$�+��c�4�||_||��|_dSr )r r )�selfr �adapters r�__init__zSpecLoaderAdapter.__init__ s���� ��g�d�m�m�� � � rc�,�t|j|��Sr )�getattrr �r�names r� __getattr__zSpecLoaderAdapter.__getattr__s���t�y�$�'�'�'rN)�__name__� __module__� __qualname__�__doc__rr�rrrrsI��������&>�%=�$�$�$�$�(�(�(�(�(rrc��eZdZdZd�Zd�ZdS)�TraversableResourcesLoaderz9 Adapt a loader to provide TraversableResources. c��||_dSr r �rr s rrz#TraversableResourcesLoader.__init__� ���� � � rc�N�t|j�����Sr )�CompatibilityFilesr �_nativers r�get_resource_readerz.TraversableResourcesLoader.get_resource_readers��!�$�)�,�,�4�4�6�6�6rN)rrrrrr'rrrr r s<�����������7�7�7�7�7rr �rc��|dkrt|g|�Ri|��S|dkr|Std�|�����)Nr(�rbz8Invalid mode value '{}', only 'r' and 'rb' are supported)r� ValueError�format)�file�mode�args�kwargss r� _io_wrapperr1 sZ�� �s�{�{��T�3�D�3�3�3�F�3�3�3� ����� � �B�I�I�$�O�O� � �rc��eZdZdZGd�dej��ZGd�dej��ZGd�dej��Zd�Z e d ���Z d �Z d �Z d �Zd S)r%zj Adapter for an existing or non-existent resource reader to provide a compatibility .files(). c�L�eZdZdZd�Zd�Zd�ZeZd�Ze d���Z d d�Z d S) �CompatibilityFiles.SpecPathzk Path tied to a module spec. Can be read and exposes the resource reader children. c�"�||_||_dSr )�_spec�_reader)rr �readers rrz$CompatibilityFiles.SpecPath.__init__6s���D�J�!�D�L�L�Lrc����jstd��St�fd��j���D����S)Nrc3�X�K�|]$}t��j|��V��%dSr )r%� ChildPathr7)�.0�pathrs �r� z6CompatibilityFiles.SpecPath.iterdir..=sI��������#�,�,�T�\�4�@�@������r)r7�iter�contents�rs`r�iterdirz#CompatibilityFiles.SpecPath.iterdir:s^����<� ��B�x�x������� �L�1�1�3�3������ rc��dS�NFrrAs r�is_filez#CompatibilityFiles.SpecPath.is_fileB����5rc��|jst�|��St�|j|��Sr )r7r%� OrphanPathr;�r�others r�joinpathz$CompatibilityFiles.SpecPath.joinpathGs8���<� <�)�4�4�U�;�;�;�%�/�/�� �e�D�D� Drc��|jjSr )r6rrAs rrz CompatibilityFiles.SpecPath.nameLs ���:�?� "rr(c�T�t|j�d��|g|�Ri|��Sr )r1r7� open_resource�rr.r/r0s r�openz CompatibilityFiles.SpecPath.openPs3���t�|�9�9�$�?�?��W��W�W�W�PV�W�W� WrN�r(� rrrrrrBrE�is_dirrK�propertyrrPrrr�SpecPathr40s������� � �  "� "� "� � � � � � ��� E� E� E� � #� #� �� #� X� X� X� X� X� XrrUc�N�eZdZdZd�Zd�Zd�Zd�Zd�Ze d���Z d d �Z d S) �CompatibilityFiles.ChildPathzw Path tied to a resource reader child. Can be read but doesn't expose any meaningful children. c�"�||_||_dSr )r7�_name)rr8rs rrz%CompatibilityFiles.ChildPath.__init__Ys��!�D�L��D�J�J�Jrc� �td��S�Nr�r?rAs rrBz$CompatibilityFiles.ChildPath.iterdir]� ����8�8�Orc�@�|j�|j��Sr )r7� is_resourcerrAs rrEz$CompatibilityFiles.ChildPath.is_file`s���<�+�+�D�I�6�6� 6rc�,�|��� Sr )rErAs rrSz#CompatibilityFiles.ChildPath.is_dircs���|�|�~�~�%� %rc�B�t�|j|��Sr )r%rHrrIs rrKz%CompatibilityFiles.ChildPath.joinpathfs��%�0�0���E�B�B� Brc��|jSr )rYrAs rrz!CompatibilityFiles.ChildPath.nameis ���:� rr(c�^�t|j�|j��|g|�Ri|��Sr )r1r7rNrrOs rrPz!CompatibilityFiles.ChildPath.openmsE���� �*�*�4�9�5�5�t��>B����FL��� rNrQrRrrrr;rWSs������� � �  � � � � � � 7� 7� 7� &� &� &� C� C� C� � � � �� � � � � � � rr;c�L�eZdZdZd�Zd�Zd�ZeZd�Ze d���Z d d�Z d S) �CompatibilityFiles.OrphanPathz� Orphan path, not tied to a module spec or resource reader. Can't be read and doesn't expose any meaningful children. c�X�t|��dkrtd���||_dS)Nrz/Need at least one path part to construct a path)�lenr+�_path)r� path_partss rrz&CompatibilityFiles.OrphanPath.__init__xs-���:����"�"� �!R�S�S�S�#�D�J�J�Jrc� �td��Sr[r\rAs rrBz%CompatibilityFiles.OrphanPath.iterdir}r]rc��dSrDrrAs rrEz%CompatibilityFiles.OrphanPath.is_file�rFrc�2�tjg|j�|�R�Sr )r%rHrhrIs rrKz&CompatibilityFiles.OrphanPath.joinpath�s ��%�0�D�$�*�D�e�D�D�D� Drc��|jdS)N�����)rhrAs rrz"CompatibilityFiles.OrphanPath.name�s���:�b�>� !rr(c� �td���)NzCan't open orphan path)�FileNotFoundErrorrOs rrPz"CompatibilityFiles.OrphanPath.open�s��#�$<�=�=� =rNrQrRrrrrHrers������� � �  $� $� $�  � � � � � ��� E� E� E� � "� "� �� "� >� >� >� >� >� >rrHc��||_dSr r r"s rrzCompatibilityFiles.__init__�r#rc��tt��5|jj�|jj��cddd��S#1swxYwYdSr )r�AttributeErrorr r r'rrAs rr7zCompatibilityFiles._reader�s��� �n� %� %� H� H��9�#�7�7�� ��G�G� H� H� H� H� H� H� H� H� H� H� H� H���� H� H� H� H� H� Hs�)A � A�Ac�8�|j}t|d��r|n|S)zB Return the native reader if it supports files(). �files)r7�hasattr)rr8s rr&zCompatibilityFiles._native�s$����� ���1�1�;�v�v�t�;rc�,�t|j|��Sr )rr7)r�attrs rrzCompatibilityFiles.__getattr__�s���t�|�T�*�*�*rc�L�t�|j|j��Sr )r%rUr r7rAs rruzCompatibilityFiles.files�s��!�*�*�4�9�d�l�C�C�CrN)rrrrr� TraversablerUr;rHrrTr7r&rrurrrr%r%*s �������� !X�!X�!X�!X�!X�3�?�!X�!X�!X�F�����C�O����>>�>�>�>�>�S�_�>�>�>�:����H�H��X�H�<�<�<�+�+�+�D�D�D�D�Drr%c�6�t|jt��S)z` Construct a package spec with traversable compatibility on the spec/loader/reader. )r�__spec__r )�packages r� wrap_specr~�s�� �W�-�/I� J� J�JrNrQ) � contextlibr�ior�rrr r1r%r~rrr�r�s��������������������� (� (� (� (� (� (� (� (� 7� 7� 7� 7� 7� 7� 7� 7�����xD�xD�xD�xD�xD�xD�xD�xD�vK�K�K�K�Kr