Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/bz2.cpython-35.pyc



��Yf�0�@sdZddddddgZdZdd	lmZdd
lZdd
lZdd
lZyddl	m
Z
Wn"ek
r�ddlm
Z
YnXddl
mZmZdZd
ZdZGdd�dej�Zddd
d
d
dd�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@seZdZdZddddd�Zdd�Zed	d
��Zdd�Zd
d�Z	dd�Z
dd�Zddd�Zd)dd�Z
d*dd�Zdd�Zd+dd�Zd,dd �Zd!d"�Zd#d$�Zejd%d&�Zd'd(�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.
    �rN�	cCs�t�|_d|_d|_t|_|dk	rCtjdt�d|koZdknskt	d��|dkr�d	}t
}n�|dkr�d}t}t|�|_
ng|dkr�d
}t}t|�|_
n=|dkrd}t}t|�|_
nt	d|f��t|ttf�rSt||�|_d|_||_n?t|d�sqt|d�r�||_||_ntd��|jt
kr�tj|jtdt�}tj|�|_n	d|_dS)a3Open a bzip2-compressed file.

        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 '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. 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.
        NFz)Use of 'buffering' argument is deprecatedr	rz%compresslevel must be between 1 and 9�r�rb�w�wb�x�xb�a�abzInvalid mode: %rT�read�writez1filename must be a str or bytes object, or a fileZtrailing_errorr)r
rr)rr)rr)rr)r�_lock�_fp�_closefp�_MODE_CLOSED�_mode�warnings�warn�DeprecationWarning�
ValueError�
_MODE_READ�_MODE_WRITEr�_compressor�
isinstance�str�bytes�
_builtin_open�hasattr�	TypeError�_compressionZDecompressReaderr�OSError�io�BufferedReader�_buffer�_pos)�self�filename�mode�	buffering�
compresslevelZ	mode_code�raw�r5�(/opt/alt/python35/lib64/python3.5/bz2.py�__init__*sL							zBZ2File.__init__cCs�|j��|jtkrdSzT|jtkr?|jj�n1|jtkrp|jj|j	j
��d|_	Wdz|jr�|jj�Wdd|_d|_t|_d|_XXWdQRXdS)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)rrrr r-�closer!rrr"�flushr)r/r5r5r6r8os 

				z
BZ2File.closecCs
|jtkS)zTrue if this file is closed.)rr)r/r5r5r6�closed�szBZ2File.closedcCs|j�|jj�S)z3Return the file descriptor for the underlying file.)�_check_not_closedr�fileno)r/r5r5r6r<�s
zBZ2File.filenocCs|j�o|jj�S)z)Return whether the file supports seeking.)�readabler-�seekable)r/r5r5r6r>�szBZ2File.seekablecCs|j�|jtkS)z/Return whether the file was opened for reading.)r;rr )r/r5r5r6r=�s
zBZ2File.readablecCs|j�|jtkS)z/Return whether the file was opened for writing.)r;rr!)r/r5r5r6�writable�s
zBZ2File.writablerc	Cs/|j�|j�|jj|�SWdQRXdS)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_readr-�peek)r/�nr5r5r6rA�s

zBZ2File.peekr	c	Cs/|j�|j�|jj|�SWdQRXdS)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)rr@r-r)r/�sizer5r5r6r�s

zBZ2File.readc	CsD|j�4|j�|dkr)tj}|jj|�SWdQRXdS)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)rr@r+�DEFAULT_BUFFER_SIZEr-�read1)r/rCr5r5r6rE�s


	z
BZ2File.read1c	Cs/|j�|j�|jj|�SWdQRXdS)zRRead bytes into b.

        Returns the number of bytes read (0 for EOF).
        N)rr@r-�readinto)r/�br5r5r6rF�s

zBZ2File.readintoc	Cset|t�s6t|d�s*td��|j�}|j�|j�|jj|�SWdQRXdS)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__zInteger argument expectedN)	r#�intr'r(rHrr@r-�readline)r/rCr5r5r6rJ�s

zBZ2File.readlinec	Cset|t�s6t|d�s*td��|j�}|j�|j�|jj|�SWdQRXdS)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.
        rHzInteger argument expectedN)	r#rIr'r(rHrr@r-�	readlines)r/rCr5r5r6rK�s

zBZ2File.readlinescCs`|j�P|j�|jj|�}|jj|�|jt|�7_t|�SWdQRXdS)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"rrrr.�len)r/�dataZ
compressedr5r5r6r�s

z
BZ2File.writec
Cs(|j�tjj||�SWdQRXdS)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)r/�seqr5r5r6rO�s
zBZ2File.writelinesc
Cs2|j�"|j�|jj||�SWdQRXdS)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_seekr-�seek)r/�offset�whencer5r5r6rQs

zBZ2File.seekc	CsB|j�2|j�|jtkr0|jj�S|jSWdQRXdS)z!Return the current file position.N)rr;rr r-�tellr.)r/r5r5r6rTs



zBZ2File.tell���rUrUrU)�__name__�
__module__�__qualname__�__doc__r7r8�propertyr:r<r>r=r?rArrErFrJrKrrOr+�SEEK_SETrQrTr5r5r5r6rs$	E


	rrcCs�d|kr.d|krvtd|f��nH|dk	rFtd��|dk	r^td��|dk	rvtd��|jdd�}t||d	|�}d|kr�tj||||�S|SdS)
a
Open a bzip2-compressed file in binary or text mode.

    The filename argument can be an actual filename (a str or bytes
    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).

    �trGzInvalid mode: %rNz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary moder
r3)r�replacerr+�
TextIOWrapper)r0r1r3�encoding�errors�newlineZbz_modeZbinary_filer5r5r6r scCs#t|�}|j|�|j�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.
    )rrr9)rMr3�compr5r5r6rHscCs�g}xs|r{t�}y|j|�}Wntk
rL|rEPn�YnX|j|�|jsotd��|j}q	Wdj|�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�)rrr*�append�eofrZunused_data�join)rMZresultsZdecomp�resr5r5r6rSs		

	
)rY�__all__�
__author__�builtinsrr&r+rr)Z	threadingr�ImportErrorZdummy_threadingZ_bz2rrrr r!rNrrrr5r5r5r6�<module>s*	
�'

Hacked By AnonymousFox1.0, Coded By AnonymousFox