o
0¦iG. ã @ s† d Z g d¢ZdZddlmZ ddlZddlZddlZddl m
Z
mZ dZdZ
dZG d d
„ d
ejƒZ dd
d„Zddd„Zdd„ 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 é )r N)r r é é c @ s´ e Zd ZdZd*ddœdd„Zdd„ Zed d
„ ƒZdd„ Zd
d„ Z dd„ Z
dd„ Zd+dd„Zd,dd„Z
d,dd„Zdd„ Zd,dd„Zd,dd „Zd!d"„ Zd#d$„ Zejfd%d&„Zd'd(„ Zd)S )-r a@ 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 C s6 d| _ d| _t| _d| krdkstdƒ‚ tdƒ‚|dv r$d}t}n1|dv r2d }t}t|ƒ| _n#|d
v r@d}t}t|ƒ| _n|dv rNd
}t}t|ƒ| _ntd|f ƒ‚t |t
ttj
fƒrkt||ƒ| _ d| _|| _nt|dƒsut|dƒr||| _ || _ntdƒ‚| jtkr–tj| j ttd�}t |¡| _dS d| _dS )a Open 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: %rTÚreadÚwritez6filename must be a str, bytes, file or PathLike object)Ztrailing_errorr )Ú_fpÚ_closefpÚ_MODE_CLOSEDÚ_modeÚ
ValueErrorÚ
_MODE_READÚ_MODE_WRITEr Ú_compressorÚ
isinstanceÚstrÚbytesÚosÚPathLikeÚ
_builtin_openÚhasattrÚ TypeErrorÚ_compressionZDecompressReaderr ÚOSErrorÚioÚBufferedReaderÚ_bufferÚ_pos)ÚselfÚfilenameÚmoder
Z mode_codeÚraw© r3 ú*/opt/alt/python310/lib64/python3.10/bz2.pyÚ__init__% sJ ÿ
ÿ
zBZ2File.__init__c C s | j tkrdS zQ| j tkr| j ¡ n| j tkr$| j | j ¡ ¡ d| _W z&| j
r=| j ¡ W d| _d| _
t| _ d| _dS W d| _d| _
t| _ d| _dS d| _d| _
t| _ d| _w z$| j
rp| j ¡ W d| _d| _
t| _ d| _w W d| _d| _
t| _ d| _w d| _d| _
t| _ d| _w )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 r- Úcloser r r r Úflushr ©r/ r3 r3 r4 r6 a sR
€
ú
ýùúýz
BZ2File.closec C s
| j tkS )zTrue if this file is closed.)r r r8 r3 r3 r4 Úclosedy s
zBZ2File.closedc C s | ¡ | j ¡ S )z3Return the file descriptor for the underlying file.)Ú_check_not_closedr Úfilenor8 r3 r3 r4 r; ~ ó
zBZ2File.filenoc C s | ¡ o| j ¡ S )z)Return whether the file supports seeking.)Úreadabler- Úseekabler8 r3 r3 r4 r> ƒ s zBZ2File.seekablec C ó | ¡ | jtkS )z/Return whether the file was opened for reading.)r: r r r8 r3 r3 r4 r= ‡ r<