B äxác·2ã$@sèdZddddddddd d d d d ddddddddddddddddddd d!d"d#d$g$Zd%d&lZd%d&lZd%d&lZd%d'lTd%d(lmZmZd%d&lZd%Z d)Z d*Z Gd+d„dej ƒZ d2d&d-d&d&d&d&d&d.œd/d!„Zed-d&d&fd0d"„Zed&d&fd1d#„Zd&S)3aSInterface 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_NONEZ CHECK_CRC32Z CHECK_CRC64Z CHECK_SHA256Z CHECK_ID_MAXZ CHECK_UNKNOWNZ FILTER_LZMA1Z FILTER_LZMA2Z FILTER_DELTAZ FILTER_X86Z FILTER_IA64Z FILTER_ARMZFILTER_ARMTHUMBZFILTER_POWERPCZ FILTER_SPARCÚ FORMAT_AUTOÚ FORMAT_XZZ FORMAT_ALONEZ FORMAT_RAWZMF_HC3ZMF_HC4ZMF_BT2ZMF_BT3ZMF_BT4Z MODE_FASTZ MODE_NORMALZPRESET_DEFAULTZPRESET_EXTREMEÚLZMACompressorÚLZMADecompressorÚLZMAFileÚ LZMAErrorÚopenÚcompressÚ decompressZis_check_supportedéN)Ú*)Ú_encode_filter_propertiesÚ_decode_filter_propertiesééc@s eZdZdZd"dddddœdd„Zdd „Zed d „ƒZd d „Zdd„Z dd„Z dd„Z d#dd„Z d$dd„Z d%dd„Zd&dd„Zdd„Zejfdd„Zd d!„ZdS)'ra@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Úréÿÿÿÿ)ÚformatÚcheckÚpresetÚfiltersc Cs&d|_d|_t|_|dkrL|dkr*tdƒ‚|dk r:tdƒ‚|dkrFt}t}n@|dkr~|dkr`t}t}t ||||d|_ d |_ ntd   |¡ƒ‚t |tttjfƒrÊd |kr®|d 7}t ||¡|_d |_||_n*t|d ƒsÞt|dƒrì||_||_ntdƒ‚|jtkr"tj|jtt||d}t |¡|_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. NF)rÚrbrzACannot specify an integrity check when opening a file for readingzICannot specify a preset compression level when opening a file for reading)ÚwÚwbÚaZabÚxZxb)rrrrr zInvalid mode: {!r}ÚbTÚreadÚwritez6filename must be a str, bytes, file or PathLike object)Ztrailing_errorrr)Ú_fpÚ_closefpÚ _MODE_CLOSEDÚ_modeÚ ValueErrorrÚ _MODE_READrÚ _MODE_WRITErÚ _compressorÚ_posrÚ isinstanceÚstrÚbytesÚosÚPathLikeÚbuiltinsrÚhasattrÚ TypeErrorÚ _compressionZDecompressReaderrrÚioÚBufferedReaderÚ_buffer) ÚselfÚfilenameÚmoderrrrZ mode_codeÚraw©r7ú)/opt/alt/python37/lib64/python3.7/lzma.pyÚ__init__1sB,    zLZMAFile.__init__cCs‚|jtkrdSzB|jtkr,|j ¡d|_n"|jtkrN|j |j  ¡¡d|_Wdz|j rd|j ¡Wdd|_d|_ t|_XXdS)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 r#r2Úcloser$rrr%Úflushr)r3r7r7r8r:†s     zLZMAFile.closecCs |jtkS)zTrue if this file is closed.)r!r )r3r7r7r8ÚclosedžszLZMAFile.closedcCs| ¡|j ¡S)z3Return the file descriptor for the underlying file.)Ú_check_not_closedrÚfileno)r3r7r7r8r>£szLZMAFile.filenocCs| ¡o|j ¡S)z)Return whether the file supports seeking.)Úreadabler2Úseekable)r3r7r7r8r@¨szLZMAFile.seekablecCs| ¡|jtkS)z/Return whether the file was opened for reading.)r=r!r#)r3r7r7r8r?¬szLZMAFile.readablecCs| ¡|jtkS)z/Return whether the file was opened for writing.)r=r!r$)r3r7r7r8Úwritable±szLZMAFile.writablecCs| ¡|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)r3Úsizer7r7r8rC¶sz LZMAFile.peekcCs| ¡|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. )rBr2r)r3rDr7r7r8rÁsz LZMAFile.readcCs"| ¡|dkrtj}|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 )rBr0ÚDEFAULT_BUFFER_SIZEr2Úread1)r3rDr7r7r8rFÊszLZMAFile.read1cCs| ¡|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. )rBr2Úreadline)r3rDr7r7r8rGÖszLZMAFile.readlinecCs:| ¡|j |¡}|j |¡|jt|ƒ7_t|ƒS)z÷Write a bytes object 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. )Z_check_can_writer%rrrr&Úlen)r3ÚdataZ compressedr7r7r8ràs   zLZMAFile.writecCs| ¡|j ||¡S)aðChange the file position. The new position is specified by offset, relative to the position indicated by whence. Possible 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. )Z_check_can_seekr2Úseek)r3ÚoffsetÚwhencer7r7r8rJísz LZMAFile.seekcCs"| ¡|jtkr|j ¡S|jS)z!Return the current file position.)r=r!r#r2Útellr&)r3r7r7r8rMÿs  z LZMAFile.tell)Nr)r)r)r)r)Ú__name__Ú __module__Ú __qualname__Ú__doc__r9r:Úpropertyr<r>r@r?rArCrrFrGrr0ÚSEEK_SETrJrMr7r7r7r8r&s  T   rr)rrrrÚencodingÚerrorsÚnewlinec Csd|kr d|krPtd|fƒ‚n0|dk r0tdƒ‚|dk r@tdƒ‚|dk rPtdƒ‚| dd¡} t|| ||||d } d|krˆt | |||¡S| SdS) a¬Open an LZMA-compressed file in binary or text 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. The mode argument can be "r", "rb" (default), "w", "wb", "x", "xb", "a", or "ab" for binary mode, or "rt", "wt", "xt", or "at" for text mode. The format, check, preset and filters arguments specify the compression settings, as for LZMACompressor, LZMADecompressor and LZMAFile. For binary mode, this function is equivalent to the LZMAFile constructor: LZMAFile(filename, mode, ...). In this case, the encoding, errors and newline arguments must not be provided. For text mode, an LZMAFile object is created, and wrapped in an io.TextIOWrapper instance with the specified encoding, error handling behavior, and line ending(s). ÚtrzInvalid mode: %rNz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary modeÚ)rrrr)r"Úreplacerr0Ú TextIOWrapper) r4r5rrrrrTrUrVZlz_modeZ binary_filer7r7r8rs   cCs t||||ƒ}| |¡| ¡S)zãCompress a block of data. Refer to LZMACompressor's docstring for a description of the optional arguments *format*, *check*, *preset* and *filters*. For incremental compression, use an LZMACompressor instead. )rrr;)rIrrrrÚcompr7r7r8r6scCsrg}xbt|||ƒ}y| |¡}Wntk r>|r8Pn‚YnX| |¡|jsXtdƒ‚|j}|sPqWd |¡S)záDecompress a block of data. Refer to LZMADecompressor's docstring for a description of the optional arguments *format*, *check* and *filters*. For incremental decompression, use an LZMADecompressor instead. zACompressed data ended before the end-of-stream marker was reachedó)rr rÚappendÚeofZ unused_dataÚjoin)rIrZmemlimitrZresultsZdecompZresr7r7r8r Bs   )r)rQÚ__all__r,r0r*Z_lzmar r r/r r#r$Z BaseStreamrrrrrr r7r7r7r8Ú s2   b-