� ���g�����ddlZddlmZddlmZddlZddlmZGd�de��ZGd�de��Z Gd �d e��Z Gd �d e��Z Gd �de��Z Gd�de��Z dS)�N)�partial)�Optional)�AbstractArchiveFileSystemc����eZdZUdZdZdZeed<dZeed<dZ eed< ddede ed e e f�fd � Z e �fd ���Zd �Zd efd�Z dd edefd�Z�xZS)�BaseCompressedFileFileSystemzFRead contents of compressed file as a filesystem with one file inside.�N�protocol� compression� extension�fo�target_protocol�target_optionsc �.��t��j|fi|��t|d��r|���n||_t t j|jfd||jddd�|pi� di���d�|pi��|_ tj � |j�d��d ��|_d |jvr'|jd |j�d ���n|j|_d |_d S) a� The compressed file system can be instantiated from any compressed file. It reads the contents of compressed file as a filesystem with one file inside, as if it was an archive. The single file inside the filesystem is named after the compresssed file, without the compression extension at the end of the filename. Args: fo (:obj:``str``): Path to compressed file. Will fetch file using ``fsspec.open()`` mode (:obj:``str``): Currently, only 'rb' accepted target_protocol(:obj:``str``, optional): To override the FS protocol inferred from a URL. target_options (:obj:``dict``, optional): Kwargs passed when instantiating the target FS. � __fspath__�rbFT)�requote_redirect_url� trust_env� client_kwargs)�moder r rz::r�.N)�super�__init__�hasattrrr r�fsspec�openr �pop�_open_with_fsspec�os�path�basename�split�compressed_name�rindex�uncompressed_name� dir_cache)�selfr r r�kwargs� __class__s ��p/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/datasets/filesystems/compression.pyrz%BaseCompressedFileFileSystem.__init__s7��� ������(�(��(�(�(�%,�R��%>�%>�F�"�-�-�/�/�/�B���!(� �K� �G� " ��$��(�(-�!���"�'�R�,�,�_�b�A�A�� " � " ��#�� " � " ��� "�w�/�/��� � �d�0C�0C�A�0F�G�G����d�*�*�*� � �!C�4�#7�#>�#>�s�#C�#C�!C� D� D��%� �� �����c�l��t���|���d��S)N�/)r�_strip_protocol�lstrip)�clsrr(s �r)r-z,BaseCompressedFileFileSystem._strip_protocol;s+����w�w�&�&�t�,�,�3�3�C�8�8�8r*c��|j�Mi|���j�|j���d|ji�}|d|i|_dSdS)N�name)r%r�fs�infor r$)r&�fs r)� _get_dirsz&BaseCompressedFileFileSystem._get_dirs@s[�� �>� !�]�4�)�)�+�+�.�3�3�D�G�<�<�]�f�d�F\�]�]�A���i��^�D�N�N�N� "� !r*rc��|������5}|���cddd��S#1swxYwYdS)N)rr�read)r&rr4s r)�catz BaseCompressedFileFileSystem.catEs��� � #� #� %� %� *� *� ,� ,� ���6�6�8�8� � � � � � � � � � � � ���� � � � � � s�A�A �A rTrc ��|�|��}|dkrtd|�d|j�d����|������S)NrzTried to read with mode z on file z opened with mode 'rb')r-� ValueErrorr rr)r&rr� block_size� autocommit� cache_optionsr's r)�_openz"BaseCompressedFileFileSystem._openIsb���#�#�D�)�)�� �4�<�<��f��f�f�t�w�f�f�f�g�g� g��%�%�'�'�,�,�.�.�.r*)rNN)rNTN)�__name__� __module__� __qualname__�__doc__� root_markerr �str�__annotations__r r r�dictr� classmethodr-r5r8r>� __classcell__)r(s@r)rr s<��������P�P��K� � �c�����K������I�s����ei�&�&��&�-5�c�]�&�S[�\`�Sa�&�&�&�&�&�&�P�9�9�9�9��[�9�,�,�,� ���������� /� /�� /�� /� /� /� /� /� /� /� /r*rc��eZdZdZdZdZdZdS)� Bz2FileSystemz?Read contents of BZ2 file as a filesystem with one file inside.�bz2z.bz2N�r?r@rArBr r r �r*r)rJrJX�#������I�I��H��K��I�I�Ir*rJc��eZdZdZdZdZdZdS)�GzipFileSystemz@Read contents of GZIP file as a filesystem with one file inside.�gzipz.gzNrLrMr*r)rPrP`s#������J�J��H��K��I�I�Ir*rPc��eZdZdZdZdZdZdS)� Lz4FileSystemz?Read contents of LZ4 file as a filesystem with one file inside.�lz4z.lz4NrLrMr*r)rSrShrNr*rSc��eZdZdZdZdZdZdS)� XzFileSystemzFRead contents of .xz (LZMA) file as a filesystem with one file inside.�xzz.xzNrLrMr*r)rVrVps#������P�P��H��K��I�I�Ir*rVc��eZdZdZdZdZdZdS)�ZstdFileSystemzK Read contents of .zstd file as a filesystem with one file inside. �zstdz.zstNrLrMr*r)rYrYxs)���������H��K��I�I�Ir*rY)r� functoolsr�typingrr�fsspec.archiverrrJrPrSrVrYrMr*r)�<module>r^sb�� � � � ������������� � � � �4�4�4�4�4�4�L/�L/�L/�L/�L/�#<�L/�L/�L/�^�����0���������1���������0���������/���������1�����r*
Memory