� I�g8M���dZddlZddlZddlmZ ddlmZn#e$r ddlmZYnwxYw ddl Z n #e$rdZ YnwxYw ddl Z ddl m Z n #e$rdZ YnwxYw ddl Z n #e$rdZ YnwxYwdZiadZdZd Zd Zd Zd Zd Z d&d�ZGd�d��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZdZdZdZdZ dZ!Gd�dej"��Z#Gd �d!e��Z$Gd"�d#e#��Z%Gd$�d%e��Z&dS)'z/Classes and functions for managing compressors.�N)� LooseVersion)�RLock)� LZ4FrameFilezMLZ4 is not installed. Install it with pip: https://python-lz4.readthedocs.io/sZF�xs�sBZs�7zXZs]s"MFc�T�t|t��s"td�|�����t|t��s"td�|�����|j�{t |jd��r?t |jd��r*t |jd��rt |jd��s'td�|j�����|tvr$|s"td �|�����|t|<dS) z�Register a new compressor. Parameters ---------- compressor_name: str. The name of the compressor. compressor: CompressorWrapper An instance of a 'CompressorWrapper'. z/Compressor name should be a string, '{}' given.zHCompressor should implement the CompressorWrapper interface, '{}' given.N�read�write�seek�tellz^Compressor 'fileobj_factory' attribute should implement the file object interface, '{}' given.z#Compressor '{}' already registered.)� isinstance�str� ValueError�format�CompressorWrapper�fileobj_factory�hasattr� _COMPRESSORS)�compressor_name� compressor�forces �a/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/joblib/compressor.py�register_compressorr-sN�� �o�s� +� +�@��'�'-�v�o�'>�'>�@�@� @� �j�"3� 4� 4�F��2�28�&��2D�2D�F�F� F� �"�.���3�V�<�<� /���3�W�=�=� /���3�V�<�<� /���3�V�<�<� /� �L� �&��!;�<�<�>�>� >��,�&�&�u�&��>� �&��1�1�3�3� 3�%/�L��!�!�!�c�(�eZdZdZdd�Zd d�Zd�ZdS) ra�A wrapper around a compressor file object. Attributes ---------- obj: a file-like object The object must implement the buffer interface and will be used internally to compress/decompress the data. prefix: bytestring A bytestring corresponding to the magic number that identifies the file format associated to the compressor. extension: str The file extension used to automatically select this compressor during a dump to a file. r�c�0�||_||_||_dS�N)r�prefix� extension)�self�objrrs r�__init__zCompressorWrapper.__init__as��"����� �"����rNc�b�|�|�|d��S|�|d|���S��0Returns an instance of a compressor file object.N�wb)� compresslevel�r�r �fileobjr's r�compressor_filez!CompressorWrapper.compressor_filefsE�� � ��'�'���6�6� 6��'�'���6C�(�E�E� Erc�.�|�|d��S�z2Returns an instance of a decompressor file object.�rbr(�r r*s r�decompressor_filez#CompressorWrapper.decompressor_filens���#�#�G�T�2�2�2r)rrr)�__name__� __module__� __qualname__�__doc__r"r+r0�rrrrQsY������ � �#�#�#�#� E�E�E�E�3�3�3�3�3rrc�0�eZdZeZdZd�Zd�Zdd�Zd�Z dS)�BZ2CompressorWrapperz.bz2c�H�t�tj|_dSd|_dSr)�bz2�BZ2Filer�r s rr"zBZ2CompressorWrapper.__init__xs%�� �?�#&�;�D� � � �#'�D� � � rc�2�t�td���dS)Nz;bz2 module is not compiled on your python standard library.)r9rr;s r�_check_versionsz$BZ2CompressorWrapper._check_versions~s%�� �;��1�2�2� 2� �;rNc��|���|�|�|d��S|�|d|���Sr$�r=rr)s rr+z$BZ2CompressorWrapper.compressor_file�sW�� ������ � ��'�'���6�6� 6��'�'���6C�(�E�E� Erc�Z�|���|�|d��}|Sr-r?r/s rr0z&BZ2CompressorWrapper.decompressor_file�s.�� �������&�&�w��5�5���rr) r1r2r3� _BZ2_PREFIXrrr"r=r+r0r5rrr7r7ssc������ �F��I�(�(�(� 2�2�2� E�E�E�E�����rr7c�4�eZdZeZdZdZd�Zd�Zdd�Z d�Z dS) �LZMACompressorWrapperz.lzma� FORMAT_ALONEc��t�2tj|_tt|j��|_dSd|_dSr)�lzma�LZMAFiler�getattr�_lzma_format_name� _lzma_formatr;s rr"zLZMACompressorWrapper.__init__�s;�� � �#'�=�D� � '��d�.D� E� E�D� � � �#'�D� � � rc�2�t�td���dS)Nz<lzma module is not compiled on your python standard library.)rFrr;s rr=z%LZMACompressorWrapper._check_versions�s%�� �<��1�2�2� 2� �<rNc�|�|�|�|d|j���S|�|d|j|���S)r%Nr&)r)r�preset)rrJr)s rr+z%LZMACompressorWrapper.compressor_file�s^�� � ��'�'���/3�/@�(�B�B� B��'�'���/3�/@�/<�(�>�>� >rc�,�tj|d��Sr-)rFrGr/s rr0z'LZMACompressorWrapper.decompressor_file�s���}�W�d�+�+�+rr) r1r2r3� _LZMA_PREFIXrrrIr"r=r+r0r5rrrCrC�se������ �F��I�&��(�(�(�2�2�2� >�>�>�>�,�,�,�,�,rrCc��eZdZeZdZdZdS)�XZCompressorWrapperz.xz� FORMAT_XZN)r1r2r3� _XZ_PREFIXrrrIr5rrrQrQ�s ������ �F��I�#���rrQc�0�eZdZeZdZd�Zd�Zdd�Zd�Z dS)�LZ4CompressorWrapperz.lz4c�>�t�t|_dSd|_dSr)�lz4rrr;s rr"zLZ4CompressorWrapper.__init__�s#�� �?�#/�D� � � �#'�D� � � rc���t�tt���tj}|�d��r |dd�}t |��t d��krtt���dS)N�v�z0.19)rWr�LZ4_NOT_INSTALLED_ERROR� __version__� startswithr)r � lz4_versions rr=z$LZ4CompressorWrapper._check_versions�sr�� �;��4�5�5� 5��o� � � !� !�#� &� &� *�%�a�b�b�/�K� � � $� $�|�F�';�';� ;� ;��4�5�5� 5� <� ;rNc��|���|�|�|d��S|�|d|���S)r%Nr&)�compression_levelr?r)s rr+z$LZ4CompressorWrapper.compressor_file�sW�� ������ � ��'�'���6�6� 6��'�'���:G�(�I�I� Irc�V�|���|�|d��Sr-r?r/s rr0z&LZ4CompressorWrapper.decompressor_file�s*�� �������#�#�G�T�2�2�2rr) r1r2r3� _LZ4_PREFIXrrr"r=r+r0r5rrrUrU�sc������ �F��I�(�(�(� 6�6�6�I�I�I�I�3�3�3�3�3rrUrZ��i c��eZdZdZejZdd�Zd�Ze d���Z d�Z d�Z d �Z d �Zd �Zd �Zd �Zd�Zd�Zdd�Zdd�Zdd�Zd�Zd�Zd�Zdd�Zd�ZdS) �BinaryZlibFilea�A file object providing transparent zlib (de)compression. TODO python2_drop: is it still needed since we dropped Python 2 support A BinaryZlibFile can act as a wrapper for an existing file object, or refer directly to a named file on disk. Note that BinaryZlibFile provides only a *binary* file interface: data read is returned as bytes, and data to be written should be given as bytes. This object is an adaptation of the BZ2File object and is compatible with versions of python >= 2.7. If filename is a str or bytes object, it gives the name of the file to be opened. Otherwise, it should be a file object, which will be used to read or write the compressed data. mode can be 'rb' for reading (default) or 'wb' for (over)writing If mode is 'wb', compresslevel can be a number between 1 and 9 specifying the level of compression: 1 produces the least compression, and 9 produces the most compression. 3 is the default. r.rdc�0�t��|_d|_d|_t|_d|_d|_||_t|t��rd|cxkrdks$ntd� |�����|dkr9t|_tj|j��|_d|_d|_n`|d krHt(|_tj|jtj|jtjd��|_ntd |�����t|t2��r#t5j||��|_d |_dSt9|d ��st9|d ��r ||_dSt;d���)NFr�����rZ� zS'compresslevel' must be an integer between 1 and 9. You provided 'compresslevel={}'r.rr&zInvalid mode: Trr z1filename must be a str or bytes object, or a file)r�_lock�_fp�_closefp� _MODE_CLOSED�_mode�_pos�_sizer'r �intrr� _MODE_READ�zlib� decompressobj�wbits� _decompressor�_buffer�_buffer_offset� _MODE_WRITE� compressobj�DEFLATED� DEF_MEM_LEVEL� _compressorr �io�openr� TypeError)r �filename�moder's rr"zBinaryZlibFile.__init__s����W�W�� ������ �!�� ��� ��� �*����-��-�-� 5�a�=�6M�6M�6M�6M�A�6M�6M�6M�6M��P�$�f�]�3�3�5�5� 5� �4�<�<�#�D�J�!%�!3�D�J�!?�!?�D� ��D�L�"#�D� � � �T�\�\�$�D�J�#�/��0B�04� �t�z�04�0B�A� G� G�D� � ��*�4�4�9�:�:� :� �h�� $� $� )��w�x��.�.�D�H� �D�M�M�M� �X�v� &� &� )�'�(�G�*D�*D� )��D�H�H�H��(�)�)� )rc�6�|j5|jtkr ddd��dS |jttfvrd|_nH|jt kr8|j�|j � ����d|_ |j r|j� ��d|_d|_ t|_d|_ d|_n�#d|_d|_ t|_d|_ d|_wxYw# |j r|j� ��d|_d|_ t|_d|_ d|_n-#d|_d|_ t|_d|_ d|_wxYwwxYw ddd��dS#1swxYwYdS)z�Flush and close the file. May be called more than once without error. Once the file is closed, any other operation on it will raise a ValueError. NFrr)rjrnrmrr�_MODE_READ_EOFrvryrkr r}�flushrl�closerwrxr;s rr�zBinaryZlibFile.close's�� �Z� ,� ,��z�\�)�)�� ,� ,� ,� ,� ,� ,� ,� ,� ,��:�*�n�!=�=�=�)-�D�&�&��Z�;�.�.��H�N�N�4�#3�#9�#9�#;�#;�<�<�<�'+�D�$�,��}�)�����(�(�(�#�D�H�$)�D�M�!-�D�J�#&�D�L�*+�D�'�'�� $�D�H�$)�D�M�!-�D�J�#&�D�L�*+�D�'�+�+�+�+��,��}�)�����(�(�(�#�D�H�$)�D�M�!-�D�J�#&�D�L�*+�D�'�'�� $�D�H�$)�D�M�!-�D�J�#&�D�L�*+�D�'�+�+�+�+�+�+�+�+�'�% ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,���� ,� ,� ,� ,� ,� ,sS�F�A%D� C�.)F�*D�F�E=� E�&)E=�*E9 �9E=�=F�F�Fc�"�|jtkS)zTrue if this file is closed.)rnrmr;s r�closedzBinaryZlibFile.closedAs���z�\�)�)rc�\�|���|j���S)z3Return the file descriptor for the underlying file.)�_check_not_closedrk�filenor;s rr�zBinaryZlibFile.filenoFs&�� ��� � � ��x��� � � rc�\�|���o|j���S)z)Return whether the file supports seeking.)�readablerk�seekabler;s rr�zBinaryZlibFile.seekableKs#���}�}���6�4�8�#4�#4�#6�#6�6rc�T�|���|jttfvS)z/Return whether the file was opened for reading.)r�rnrrr�r;s rr�zBinaryZlibFile.readableOs&�� ��� � � ��z�j�.�9�9�9rc�J�|���|jtkS)z/Return whether the file was opened for writing.)r�rnryr;s r�writablezBinaryZlibFile.writableTs!�� ��� � � ��z�[�(�(rc��|jrFt|jdd��}d}|�|d�|��z }|dz }t |���dS)N�namezI/O operation on closed filez {}�.)r�rHrkrr)r �fname�msgs rr�z BinaryZlibFile._check_not_closed[s_�� �;� "��D�H�f�d�3�3�E�0�C�� ��u�|�|�E�*�*�*�� �3�J�C��S�/�/� !�  "� "rc��|jttfvr(|���t jd���dS)NzFile not open for reading)rnrrr�r�r~�UnsupportedOperationr;s r�_check_can_readzBinaryZlibFile._check_can_readds@�� �:�j�.�9� 9� 9� � "� "� $� $� $��)�*E�F�F� F� :� 9rc�v�|jtkr(|���tjd���dS)NzFile not open for writing)rnryr�r~r�r;s r�_check_can_writezBinaryZlibFile._check_can_writeis;�� �:�� $� $� � "� "� $� $� $��)�*E�F�F� F� %� $rc���|jttfvr(|���t jd���|j���st jd���dS)Nz3Seeking is only supported on files open for readingz3The underlying file object does not support seeking)rnrrr�r�r~r�rkr�r;s r�_check_can_seekzBinaryZlibFile._check_can_seekns��� �:�j�.�9� 9� 9� � "� "� $� $� $��)�+F�G�G� G��x� � �"�"� F��)�+E�F�F� F� F� Frc��|jtkrdS|jt|j��kr� |jjp|j�t��}|st� |j� |��|_n)#t$rt|_|j |_ YdSwxYwd|_|jt|j��k��dS)NFrT)rnr�rx�lenrwrv� unused_datarkr� _BUFFER_SIZE�EOFError� decompressrorp)r �rawblocks r� _fill_bufferzBinaryZlibFile._fill_bufferxs��� �:�� '� '��5��!�S���%6�%6�6�6� G� �.�:�8� �H�M�M�,�7�7���#�"�N�#� $�1�<�<�X�F�F�� � �� � � � �+�� �!�Y�� ��u�u�  ����#$�D� ��!�S���%6�%6�6�6��ts�4B�"B,�+B,Tc�R�|j|jd�|_d|_g}|���rY|r|�|j��|xjt |j��z c_d|_|����Y|rd�|��SdS�Nrr)rwrxr��appendror��join)r � return_data�blockss r� _read_allzBinaryZlibFile._read_all�s����|�D�$7�$8�$8�9�� ���������!�!� �� ,�� � �d�l�+�+�+� �I�I��T�\�*�*� *�I�I��D�L� ���!�!� � � $��8�8�F�#�#� #� $� $rc��|j|z}|t|j��kr>|j|j|�}||_|xjt|��z c_|r|ndS|j|jd�|_d|_g}|dkr�|���r�|t|j��kr|jd|�}||_n|j}d|_|r|�|��|xjt|��z c_|t|��z}|dkr|�����|rd�|��SdSr�)rxr�rwror�r�r�)r �n_bytesr��end�datar�s r� _read_blockzBinaryZlibFile._read_block�sc���!�G�+�� �#�d�l�#�#� #� #��<�� 3�S� 8�9�D�"%�D� � �I�I��T��� "�I�I�&�0�4�4�D� 0��|�D�$7�$8�$8�9�� ��������k�k�d�/�/�1�1�k���T�\�*�*�*�*��|�H�W�H�-��&-��#�#��|��"�� �� $�� � �d�#�#�#� �I�I��T��� "�I�I� �s�4�y�y� �G���k�k�d�/�/�1�1�k� � $��8�8�F�#�#� #� $� $rrhc� �|j5|���|dkr ddd��dS|dkr |���cddd��S|�|��cddd��S#1swxYwYdS)z�Read up to size uncompressed bytes from the file. If size is negative or omitted, read until EOF is reached. Returns b'' if the file is already at EOF. rNr)rjr�r�r�)r �sizes rrzBinaryZlibFile.read�s �� �Z� .� .� � � � "� "� "��q�y�y�� .� .� .� .� .� .� .� .������~�~�'�'�  .� .� .� .� .� .� .� .��'�'��-�-� .� .� .� .� .� .� .� .� .� .� .� .���� .� .� .� .� .� .s�A8�A8�A8�8A<�?A<c��|j5tj�||��cddd��S#1swxYwYdS)z_Read up to len(b) bytes into b. Returns the number of bytes read (0 for EOF). N)rjr~�BufferedIOBase�readinto)r �bs rr�zBinaryZlibFile.readinto�s��� �Z� 7� 7��$�-�-�d�A�6�6� 7� 7� 7� 7� 7� 7� 7� 7� 7� 7� 7� 7���� 7� 7� 7� 7� 7� 7s � 5�9�9c�~�|j5|���t|t��r|���}|j�|��}|j�|��|xj t|��z c_ t|��cddd��S#1swxYwYdS)z�Write a byte string to the file. Returns the number of uncompressed bytes written, which is always len(data). Note that due to buffering, the file on disk may not reflect the data written until close() is called. N) rjr�r � memoryview�tobytesr}�compressrkr ror�)r r�� compresseds rr zBinaryZlibFile.write�s����Z� � � � !� !� #� #� #��$� �+�+� &��|�|�~�~���)�2�2�4�8�8�J� �H�N�N�:� &� &� &� �I�I��T��� "�I�I��t�9�9� � � � � � � � � � � � ���� � � � � � s�BB2�2B6�9B6c��|j�dd��t|_d|_t j|j��|_d|_ d|_ dSr�) rkr rrrnrorsrtrurvrwrxr;s r�_rewindzBinaryZlibFile._rewind�sP�� �� � �a������� ��� �!�/�� �;�;����� �����rrc��|j5|���|dkrnU|dkr |j|z}nD|dkr,|jdkr|�d���|j|z}nt d|�����||jkr|���n ||jz}|�|d���|jcddd��S#1swxYwYdS)a�Change the file position. The new position is specified by offset, relative to the position indicated by whence. Values for whence are: 0: start of stream (default); offset must not be negative 1: current stream position 2: end of stream; offset must not be positive Returns the new file position. Note that seeking is emulated, so depending on the parameters, this operation may be extremely slow. rrZrcF)r�zInvalid value for whence: N)rjr�rorpr�rr�r�)r �offset�whences rr zBinaryZlibFile.seek�s<���Z� � � � � � "� "� "���{�{���1�����V�+����1����:��>�>��N�N�u�N�5�5�5���f�,��� �j�6�6�!K�L�L�L��� �!�!�� � ������$�)�#�� � � �V�� � 7� 7� 7��9�3 � � � � � � � � � � � ���� � � � � � s�B8C � C�Cc�z�|j5|���|jcddd��S#1swxYwYdS)z!Return the current file position.N)rjr�ror;s rr zBinaryZlibFile.tells��� �Z� � � � "� "� $� $� $��9� � � � � � � � � � � � ���� � � � � � s �0�4�4N)r.rd)T)rh)r)r1r2r3r4rs� MAX_WBITSrur"r��propertyr�r�r�r�r�r�r�r�r�r�r�r�rr�r r�r r r5rrrfrf�s���������. �N�E�$)�$)�$)�$)�L,�,�,�4�*�*��X�*�!�!�!� 7�7�7�:�:�:� )�)�)�"�"�"�G�G�G� G�G�G� F�F�F����. $� $� $� $� $�$�$�$�8 .� .� .� .�7�7�7����& � � �(�(�(�(�T����rrfc��eZdZd�ZdS)�ZlibCompressorWrapperc�V�t�|ttd���dS)Nz.z�r!rr)rr"rf� _ZLIB_PREFIXr;s rr"zZlibCompressorWrapper.__init__ s7���"�"�4�^�*6�$� #� H� H� H� H� HrN�r1r2r3r"r5rrr�r�s(������H�H�H�H�Hrr�c��eZdZdZdZdS)�BinaryGzipFilea A file object providing transparent gzip (de)compression. If filename is a str or bytes object, it gives the name of the file to be opened. Otherwise, it should be a file object, which will be used to read or write the compressed data. mode can be 'rb' for reading (default) or 'wb' for (over)writing If mode is 'wb', compresslevel can be a number between 1 and 9 specifying the level of compression: 1 produces the least compression, and 9 produces the most compression. 3 is the default. �N)r1r2r3r4rur5rrr�r�%s������ � � �E�E�Err�c��eZdZd�ZdS)�GzipCompressorWrapperc�V�t�|ttd���dS)Nz.gzr�)rr"r�� _GZIP_PREFIXr;s rr"zGzipCompressorWrapper.__init__8s7���"�"�4�^�*6�%� #� I� I� I� I� IrNr�r5rrr�r�6s(������I�I�I�I�Irr�)F)'r4r~rs�joblib.backportsr� threadingr� ImportError�dummy_threadingr9rW� lz4.framerrFr[r� _ZFILE_PREFIXr�r�rArSrOrbrrr7rCrQrUrmrrr�ryr�r�rfr�r�r�r5rr�<module>r�s?��5�5� � � � � � � � �)�)�)�)�)�)�&����������&�&�&�%�%�%�%�%�%�%�%�&������J�J�J�J������ �C�C�C�������J�J�J�&�&�&�&�&�&�&������ �C�C�C�������K�K�K�K������ �D�D�D�����@��� �� �� �� �� � $� �� �!� �$�!/�!/�!/�!/�H3�3�3�3�3�3�3�3�D�����,����@,�,�,�,�,�-�,�,�,�B$�$�$�$�$�/�$�$�$� 3� 3� 3� 3� 3�,� 3� 3� 3�J� � � ���� �� �t�t�t�t�t�R�&�t�t�t�n H�H�H�H�H�-�H�H�H������^����"I�I�I�I�I�-�I�I�I�I�Is;�� '�'�0�:�:� A � A�A�A�A&�%A&
Memory