AlkantarClanX12

Your IP : 3.22.70.169


Current Path : /proc/thread-self/root/lib64/python3.8/__pycache__/
Upload File :
Current File : //proc/thread-self/root/lib64/python3.8/__pycache__/bz2.cpython-38.pyc

U

e5d1�@s�dZddddddgZdZdd	lmZdd
lZdd
lZdd
lZdd
l	Z	ddl
mZddlm
Z
mZdZd
ZdZe�ZGdd�de	j�Zddd�Zddd�Zdd�Zd
S)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)�RLock)rr��c@s�eZdZdZdedfdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zd)dd�Z
d*dd�Zd+dd�Zdd�Zd,dd�Zd-dd�Zd d!�Zd"d#�Zejfd$d%�Zd&d'�Zd(S).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�	cCsTt�|_d|_d|_t|_|tk	r2tjdt	dd�d|krFdksPnt
d��|d	krbd
}t}nb|dkr~d}t}t
|�|_nF|d
kr�d}t}t
|�|_n*|dkr�d}t}t
|�|_nt
d|f��t|tttjf�r�t||�|_d|_||_n.t|d��st|d��r||_||_ntd��|jtk�rJtj|jttd�}t�|�|_nd|_dS)aOOpen 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'.

        buffering is ignored since Python 3.0. Its use is deprecated.

        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.
        NFzGUse of 'buffering' argument is deprecated and ignored since Python 3.0.�)�
stacklevelr	rz%compresslevel must be between 1 and 9)�r�rbr)�w�wbr)�x�xbr)�a�abr�Invalid mode: %rT�read�writez6filename must be a str, bytes, file or PathLike object)Ztrailing_errorr)r�_lock�_fp�_closefp�_MODE_CLOSED�_mode�	_sentinel�warnings�warn�DeprecationWarning�
ValueError�
_MODE_READ�_MODE_WRITEr�_compressor�
isinstance�str�bytes�os�PathLike�
_builtin_open�hasattr�	TypeError�_compressionZDecompressReaderr�OSError�io�BufferedReader�_buffer�_pos)�self�filename�mode�	buffering�
compresslevelZ	mode_code�raw�r;�/usr/lib64/python3.8/bz2.py�__init__)sT��zBZ2File.__init__cCs�|j��|jtkr W5QR�dSz<|jtkr8|j��n"|jtkrZ|j�	|j
���d|_
W5z|jrp|j��W5d|_d|_t|_d|_XXW5QRXdS)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)rrrrrr3�closer$r%rr&�flush�r5r;r;r<r>ps 



z
BZ2File.closecCs
|jtkS)zTrue if this file is closed.)rrr@r;r;r<�closed�szBZ2File.closedcCs|��|j��S)z3Return the file descriptor for the underlying file.)�_check_not_closedr�filenor@r;r;r<rC�szBZ2File.filenocCs|��o|j��S)z)Return whether the file supports seeking.)�readabler3�seekabler@r;r;r<rE�szBZ2File.seekablecCs|��|jtkS)z/Return whether the file was opened for reading.)rBrr$r@r;r;r<rD�szBZ2File.readablecCs|��|jtkS)z/Return whether the file was opened for writing.)rBrr%r@r;r;r<�writable�szBZ2File.writablerc
Cs2|j�"|��|j�|�W5QR�SQRXdS)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.
        N)r�_check_can_readr3�peek)r5�nr;r;r<rH�szBZ2File.peek���c
Cs2|j�"|��|j�|�W5QR�SQRXdS)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.
        N)rrGr3r�r5�sizer;r;r<r�szBZ2File.readc
Cs@|j�0|��|dkrtj}|j�|�W5QR�SQRXdS)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.
        rN)rrGr1�DEFAULT_BUFFER_SIZEr3�read1rKr;r;r<rN�s
z
BZ2File.read1c
Cs2|j�"|��|j�|�W5QR�SQRXdS)zRRead bytes into b.

        Returns the number of bytes read (0 for EOF).
        N)rrGr3�readinto)r5�br;r;r<rO�szBZ2File.readintoc
CsVt|t�s$t|d�std��|��}|j�"|��|j�|�W5QR�SQRXdS)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 expectedN)	r'�intr-r.rQrrGr3�readlinerKr;r;r<rT�s

zBZ2File.readlinec
CsVt|t�s$t|d�std��|��}|j�"|��|j�|�W5QR�SQRXdS)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.
        rQrRN)	r'rSr-r.rQrrGr3�	readlinesrKr;r;r<rU�s

zBZ2File.readlinesc
CsX|j�H|��|j�|�}|j�|�|jt|�7_t|�W5QR�SQRXdS)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)rZ_check_can_writer&rrrr4�len)r5�dataZ
compressedr;r;r<r�sz
BZ2File.writec
Cs,|j�tj�||�W5QR�SQRXdS)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.
        N)rr/�
BaseStream�
writelines)r5�seqr;r;r<rY�szBZ2File.writelinesc
Cs4|j�$|��|j�||�W5QR�SQRXdS)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.
        N)rZ_check_can_seekr3�seek)r5�offset�whencer;r;r<r[szBZ2File.seekc
CsL|j�<|��|jtkr0|j��W5QR�S|jW5QR�SQRXdS)z!Return the current file position.N)rrBrr$r3�tellr4r@r;r;r<r^s

zBZ2File.tellN)r)rJ)rJ)rJ)rJ)�__name__�
__module__�__qualname__�__doc__rr=r>�propertyrArCrErDrFrHrrNrOrTrUrrYr1�SEEK_SETr[r^r;r;r;r<rs&	G





	

rrcCs�d|kr d|krPtd|f��n0|dk	r0td��|dk	r@td��|dk	rPtd��|�dd�}t|||d	�}d|kr�t�||||�S|SdS)
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).

    �trPrNz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary moder)r9)r#�replacerr1�
TextIOWrapper)r6r7r9�encoding�errors�newlineZbz_modeZbinary_filer;r;r<r!scCst|�}|�|�|��S)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?)rWr9�compr;r;r<rJscCshg}|r^t�}z|�|�}Wn tk
r<|r6Yq^n�YnX|�|�|jsVtd��|j}qd�|�S)zjDecompress a block of data.

    For incremental decompression, use a BZ2Decompressor object instead.
    zACompressed data ended before the end-of-stream marker was reached�)rrr0�append�eofr#Zunused_data�join)rWZresultsZdecomp�resr;r;r<rUs
)rrNNN)r)rb�__all__�
__author__�builtinsrr,r1r*r r/Z	threadingrZ_bz2rrrr$r%�objectrrXrrrr;r;r;r<�<module>s6��
)