File: //lib64/python3.6/__pycache__/lzma.cpython-36.pyc
3
  \�2  �            $   @   s�   d Z ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$g$Zd%d&lZd%d&lZd%d&lZd%d'lT d%d(lmZmZ d%d&lZd%Z	d)Z
d*ZG d+d� dej�Z
d1d&d2d&d&d&d&d&d-�d.d!�Zed3d&d&fd/d"�Zed&d&fd0d#�Zd&S )4aS  Interface to the liblzma compression library.
This module provides a class for reading and writing compressed files,
classes for incremental (de)compression, and convenience functions for
one-shot (de)compression.
These classes and functions support both the XZ and legacy LZMA
container formats, as well as raw compressed data streams.
Z
CHECK_NONEZCHECK_CRC32ZCHECK_CRC64ZCHECK_SHA256ZCHECK_ID_MAXZ
CHECK_UNKNOWNZFILTER_LZMA1ZFILTER_LZMA2ZFILTER_DELTAZ
FILTER_X86ZFILTER_IA64Z
FILTER_ARMZFILTER_ARMTHUMBZFILTER_POWERPCZFILTER_SPARC�FORMAT_AUTO�	FORMAT_XZZFORMAT_ALONEZ
FORMAT_RAWZMF_HC3ZMF_HC4ZMF_BT2ZMF_BT3ZMF_BT4Z	MODE_FASTZMODE_NORMALZPRESET_DEFAULTZPRESET_EXTREME�LZMACompressor�LZMADecompressor�LZMAFile�	LZMAError�open�compress�
decompressZis_check_supported�    N)�*)�_encode_filter_properties�_decode_filter_properties�   �   c               @   s�   e Zd ZdZd"dd#ddd�dd�Zdd	� Zed
d� �Zdd
� Zdd� Z	dd� Z
dd� Zd%dd�Zd'dd�Z
d)dd�Zd+dd�Zdd� Zejfdd�Zd d!� ZdS ),r   a@  A file object providing transparent LZMA (de)compression.
    An LZMAFile can act as a wrapper for an existing file object, or
    refer directly to a named file on disk.
    Note that LZMAFile provides a *binary* file interface - data read
    is returned as bytes, and data to be written must be given as bytes.
    N�rr   )�format�check�preset�filtersc      	      C   s&  d| _ d| _t| _|dkrL|dkr*td��|dk	r:td��|dkrFt}t}n@|dkr~|dkr`t}t}t	||||d�| _
d| _ntdj|���t
|tttjf�r�d|kr�|d7 }tj||�| _ d| _|| _n*t|d�s�t|d�r�|| _ || _ntd��| jtk�r"tj| j tt||d�}tj|�| _dS )a�  Open an LZMA-compressed file in binary mode.
        filename can be either an actual file name (given as a str,
        bytes, or PathLike object), in which case the named file is
        opened, or it can be an existing file object to read from or
        write to.
        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" respectively.
        format specifies the container format to use for the file.
        If mode is "r", this defaults to FORMAT_AUTO. Otherwise, the
        default is FORMAT_XZ.
        check specifies the integrity check to use. This argument can
        only be used when opening a file for writing. For FORMAT_XZ,
        the default is CHECK_CRC64. FORMAT_ALONE and FORMAT_RAW do not
        support integrity checks - for these formats, check must be
        omitted, or be CHECK_NONE.
        When opening a file for reading, the *preset* argument is not
        meaningful, and should be omitted. The *filters* argument should
        also be omitted, except when format is FORMAT_RAW (in which case
        it is required).
        When opening a file for writing, the settings used by the
        compressor can be specified either as a preset compression
        level (with the *preset* argument), or in detail as a custom
        filter chain (with the *filters* argument). For FORMAT_XZ and
        FORMAT_ALONE, the default is to use the PRESET_DEFAULT preset
        level. For FORMAT_RAW, the caller must always specify a filter
        chain; the raw compressor does not support preset compression
        levels.
        preset (if provided) should be an integer in the range 0-9,
        optionally OR-ed with the constant PRESET_EXTREME.
        filters (if provided) should be a sequence of dicts. Each dict
        should have an entry for "id" indicating ID of the filter, plus
        additional entries for options to the filter.
        NFr   �rbr   zACannot specify an integrity check when opening a file for readingzICannot specify a preset compression level when opening a file for reading�w�wb�a�ab�x�xb)r   r   r   r   r
   zInvalid mode: {!r}�bT�read�writez6filename must be a str, bytes, file or PathLike object)Ztrailing_errorr   r   )r   r   ���)r   r   r   r   r   r   )�_fp�_closefp�_MODE_CLOSED�_mode�
ValueErrorr   �
_MODE_READr   �_MODE_WRITEr   �_compressor�_posr   �
isinstance�str�bytes�os�PathLike�builtinsr   �hasattr�	TypeError�_compressionZDecompressReaderr   r   �io�BufferedReader�_buffer)	�self�filename�moder   r   r   r   Z	mode_code�raw� r9   �/usr/lib64/python3.6/lzma.py�__init__1   sB    ,
zLZMAFile.__init__c             C   s�   | j tkrdS zB| j tkr,| jj�  d| _n"| j tkrN| jj| jj	� � d| _W dz| j
rd| jj�  W dd| _d| _
t| _ X X dS )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#   r"