ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/bz2.cpython-311.pyc

�

�fG.���dZgd�ZdZddlmZddlZddlZddlZddl	m
Z
mZdZdZ
dZGd	�d
ej��Z		dd
�Zdd�Zd�ZdS)z�Interface to the libbzip2 compression library.

This module provides a file interface, classes for incremental
(de)compression, and functions for one-shot (de)compression.
)�BZ2File�
BZ2Compressor�BZ2Decompressor�open�compress�
decompressz%Nadeem Vawda <nadeem.vawda@gmail.com>�)rN)rr��c��eZdZdZddd�d�Zd�Zed���Zd�Zd	�Z	d
�Z
d�Zdd
�Zdd�Z
dd�Zd�Zdd�Zdd�Zd�Zd�Zejfd�Zd�ZdS)ra@A file object providing transparent bzip2 (de)compression.

    A BZ2File can act as a wrapper for an existing file object, or refer
    directly to a named file on disk.

    Note that BZ2File provides a *binary* file interface - data read is
    returned as bytes, and data to be written should be given as bytes.
    �r�	��
compresslevelc�D�d|_d|_t|_d|cxkrdksnt	d���|dvr
d}t
}nx|dvrd	}t}t|��|_nV|d
vrd}t}t|��|_n4|dvrd
}t}t|��|_nt	d|�����t|tttj
f��r$t||��|_d|_||_n>t|d��st|d��r||_||_nt!d���|jt
krAt#j|jt&t(���}t+j|��|_dSd|_dS)aOpen a bzip2-compressed file.

        If filename is a str, bytes, or PathLike 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 'r' for reading (default), 'w' for (over)writing,
        'x' for creating exclusively, or 'a' for appending. These can
        equivalently be given as 'rb', 'wb', 'xb', and 'ab'.

        If mode is 'w', 'x' or 'a', compresslevel can be a number between 1
        and 9 specifying the level of compression: 1 produces the least
        compression, and 9 (default) produces the most compression.

        If mode is 'r', the input file may be the concatenation of
        multiple compressed streams.
        NFr	r
z%compresslevel must be between 1 and 9)�r�rbr)�w�wbr)�x�xbr)�a�abr�Invalid mode: T�read�writez6filename must be a str, bytes, file or PathLike object)�trailing_errorr)�_fp�_closefp�_MODE_CLOSED�_mode�
ValueError�
_MODE_READ�_MODE_WRITEr�_compressor�
isinstance�str�bytes�os�PathLike�
_builtin_open�hasattr�	TypeError�_compression�DecompressReaderr�OSError�io�BufferedReader�_buffer�_pos)�self�filename�moder�	mode_code�raws      �*/opt/alt/python311/lib64/python3.11/bz2.py�__init__zBZ2File.__init__%s���$�����
�!��
��]�'�'�'�'�a�'�'�'�'��D�E�E�E��?�"�"��D�"�I�I�
�[�
 �
 ��D�#�I�,�]�;�;�D���
�[�
 �
 ��D�#�I�,�]�;�;�D���
�[�
 �
 ��D�#�I�,�]�;�;�D����*�4�4�9�:�:�:��h��e�R�[� 9�:�:�	V�$�X�t�4�4�D�H� �D�M�"�D�J�J�
�X�v�
&�
&�	V�'�(�G�*D�*D�	V��D�H�"�D�J�J��T�U�U�U��:��#�#��/�����9�9�9�C��,�S�1�1�D�L�L�L��D�I�I�I�c��|jtkrdS	|jtkr|j���nH|jt
kr8|j�|j�	����d|_	|j
r|j���d|_d|_
t|_d|_dS#d|_d|_
t|_d|_wxYw#	|j
r|j���d|_d|_
t|_d|_n&#d|_d|_
t|_d|_wxYwwxYw)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.
        NF)r rr"r2�closer#rrr$�flushr�r4s r9r=z
BZ2File.closeasZ���:��%�%��F�	$��z�Z�'�'���"�"�$�$�$�$���{�*�*�����t�/�5�5�7�7�8�8�8�#'�� �
$��=�%��H�N�N�$�$�$���� %��
�)��
�#������ ��� %��
�)��
�#���#�#�#�#��
$��=�%��H�N�N�$�$�$���� %��
�)��
�#����� ��� %��
�)��
�#���#�#�#�#�#�#�#�#s0�A2C0� C
�
#C-�0E�2 D4�"E�4#E�Ec�"�|jtkS)zTrue if this file is closed.)r rr?s r9�closedzBZ2File.closedys���z�\�)�)r;c�\�|���|j���S)z3Return the file descriptor for the underlying file.)�_check_not_closedr�filenor?s r9rDzBZ2File.fileno~s&����� � � ��x��� � � r;c�\�|���o|j���S)z)Return whether the file supports seeking.)�readabler2�seekabler?s r9rGzBZ2File.seekable�s#���}�}���:�4�<�#8�#8�#:�#:�:r;c�J�|���|jtkS)z/Return whether the file was opened for reading.)rCr r"r?s r9rFzBZ2File.readable�s!����� � � ��z�Z�'�'r;c�J�|���|jtkS)z/Return whether the file was opened for writing.)rCr r#r?s r9�writablezBZ2File.writable�s!����� � � ��z�[�(�(r;rc�^�|���|j�|��S)z�Return buffered data without advancing the file position.

        Always returns at least one byte of data, unless at EOF.
        The exact number of bytes returned is unspecified.
        )�_check_can_readr2�peek)r4�ns  r9rMzBZ2File.peek�s.��	
�������|� � ��#�#�#r;���c�^�|���|j�|��S)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.
        )rLr2r�r4�sizes  r9rzBZ2File.read�s,��	
�������|� � ��&�&�&r;c��|���|dkrtj}|j�|��S)z�Read up to size uncompressed bytes, while trying to avoid
        making multiple reads from the underlying stream. Reads up to a
        buffer's worth of data if size is negative.

        Returns b'' if the file is at EOF.
        r)rLr0�DEFAULT_BUFFER_SIZEr2�read1rQs  r9rUz
BZ2File.read1�s=��	
�������!�8�8��)�D��|�!�!�$�'�'�'r;c�^�|���|j�|��S)zRRead bytes into b.

        Returns the number of bytes read (0 for EOF).
        )rLr2�readinto)r4�bs  r9rWzBZ2File.readinto�s,��
	
�������|�$�$�Q�'�'�'r;c���t|t��s3t|d��std���|���}|���|j�|��S)a
Read a line of uncompressed bytes from the file.

        The terminating newline (if present) is retained. If size is
        non-negative, no more than size bytes will be read (in which
        case the line may be incomplete). Returns b'' if already at EOF.
        �	__index__�Integer argument expected)r%�intr+r,rZrLr2�readlinerQs  r9r]zBZ2File.readline�sn���$��$�$�	$��4��-�-�
=�� ;�<�<�<��>�>�#�#�D��������|�$�$�T�*�*�*r;c���t|t��s3t|d��std���|���}|���|j�|��S)z�Read a list of lines of uncompressed bytes from the file.

        size can be specified to control the number of lines read: no
        further lines will be read once the total size of the lines read
        so far equals or exceeds size.
        rZr[)r%r\r+r,rZrLr2�	readlinesrQs  r9r_zBZ2File.readlines�sn���$��$�$�	$��4��-�-�
=�� ;�<�<�<��>�>�#�#�D��������|�%�%�d�+�+�+r;c�:�|���t|ttf��rt	|��}nt|��}|j}|j�|��}|j	�
|��|xj|z
c_|S)aWrite a byte string to the file.

        Returns the number of uncompressed bytes written, which is
        always the length of data in bytes. Note that due to buffering,
        the file on disk may not reflect the data written until close()
        is called.
        )�_check_can_writer%r'�	bytearray�len�
memoryview�nbytesr$rrrr3)r4�data�length�
compresseds    r9rz
BZ2File.write�s���	
�������d�U�I�.�/�/�	!���Y�Y�F�F��d�#�#�D��[�F��%�.�.�t�4�4�
�����z�"�"�"��	�	�V��	�	��
r;c�B�tj�||��S)z�Write a sequence of byte strings to the file.

        Returns the number of uncompressed bytes written.
        seq can be any iterable yielding byte strings.

        Line separators are not added between the written byte strings.
        )r-�
BaseStream�
writelines)r4�seqs  r9rkzBZ2File.writelines�s���&�1�1�$��<�<�<r;c�`�|���|j�||��S)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.
        )�_check_can_seekr2�seek)r4�offset�whences   r9rozBZ2File.seek�s.��	
�������|� � ���0�0�0r;c��|���|jtkr|j���S|jS)z!Return the current file position.)rCr r"r2�tellr3r?s r9rszBZ2File.tells=����� � � ��:��#�#��<�$�$�&�&�&��y�r;N)r)r)rO)�__name__�
__module__�__qualname__�__doc__r:r=�propertyrArDrGrFrJrMrrUrWr]r_rrkr0�SEEK_SETrors�r;r9rrs`��������:�A�:�:�:�:�:�x$�$�$�0�*�*��X�*�!�!�!�
;�;�;�(�(�(�
)�)�)�

$�
$�
$�
$�'�'�'�'�
(�
(�
(�
(�(�(�(�+�+�+�+�,�,�,�,����*=�=�=�#%�+�1�1�1�1�$����r;rrr
c�P�d|vrd|vrtd|�����n3|�td���|�td���|�td���|�dd��}t|||�	��}d|vr+tj|��}tj||||��S|S)
aOpen a bzip2-compressed file in binary or text mode.

    The filename argument can be an actual filename (a str, bytes, or
    PathLike object), or an existing file object to read from or write
    to.

    The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or
    "ab" for binary mode, or "rt", "wt", "xt" or "at" for text mode.
    The default mode is "rb", and the default compresslevel is 9.

    For binary mode, this function is equivalent to the BZ2File
    constructor: BZ2File(filename, mode, compresslevel). In this case,
    the encoding, errors and newline arguments must not be provided.

    For text mode, a BZ2File object is created, and wrapped in an
    io.TextIOWrapper instance with the specified encoding, error
    handling behavior, and line ending(s).

    �trXrNz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary moderr)r!�replacerr0�
text_encoding�
TextIOWrapper)r5r6r�encoding�errors�newline�bz_mode�binary_files        r9rrs���*�d�{�{��$�;�;��*�4�4�9�:�:�:�����O�P�P�P����M�N�N�N����N�O�O�O��l�l�3��#�#�G��(�G�=�I�I�I�K�
�d�{�{��#�H�-�-�����X�v�w�G�G�G��r;c�t�t|��}|�|��|���zS)z�Compress a block of data.

    compresslevel, if given, must be a number between 1 and 9.

    For incremental compression, use a BZ2Compressor object instead.
    )rrr>)rfr�comps   r9rr9s0����'�'�D��=�=���������-�-r;c��g}|rlt��}	|�|��}n#t$r|rYn9�wxYw|�|��|jstd���|j}|�ld�|��S)zjDecompress a block of data.

    For incremental decompression, use a BZ2Decompressor object instead.
    zACompressed data ended before the end-of-stream marker was reachedr;)rrr/�append�eofr!�unused_data�join)rf�results�decomp�ress    r9rrDs���
�G�
�
"� �"�"��	��#�#�D�)�)�C�C���	�	�	��
����		����
	���s�����z�	A��@�A�A�
A��!���
"��8�8�G���s�*�:�:)rr
NNN)r
)rw�__all__�
__author__�builtinsrr*r0r(r-�_bz2rrrr"r#rjrrrrzr;r9�<module>r�s����-�-�-��5�
�*�*�*�*�*�*�	�	�	�	�	�	�	�	�����/�/�/�/�/�/�/�/����
���r�r�r�r�r�l�%�r�r�r�j-.�-1�'�'�'�'�T.�.�.�.�����r;

Zerion Mini Shell 1.0