Files
952-11/env/python/dll/Python312/Lib/__pycache__/bz2.cpython-312.pyc
T

153 lines
15 KiB
Plaintext
Raw Normal View History

2024-08-19 17:05:14 +08:00
Ë
*åfŸ/ãó˜—dZgd¢ZdZddlmZddlZddlZddlZddl m
Z
m Z dZ dZ
dZGd „d
ej«Z dd „Zdd „Zd
„Zy)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)rréécóª—eZdZdZdddœd„Zd„Zed„«Zd„Zd„Z d „Z
d
„Z dd „Z dd „Z
dd
„Zd„Zdd„Zdd„Zd„Zd„Zej*fd„Zd„Zy)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.
é ©Ú
compresslevelcó
—d|_d|_t|_d|cxkrdkst d«‚t d«‚|dvr d}t
}ne|dvrd }t }t|«|_nH|d
vrd }t }t|«|_n+|d vrd
}t }t|«|_nt d|›�«‚t|tttjf«r t||«|_d|_||_n2t|d«s t|d«r||_||_n t!d«‚|jt
k(rEt#j$|jt&t(¬«}t+j,|«|_yd|_y)aOpen 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: TÚreadÚwritez6filename must be a str, bytes, file or PathLike object)Útrailing_errorr)Ú_fpÚ_closefpÚ _MODE_CLOSEDÚ_modeÚ
ValueErrorÚ
_MODE_READÚ _MODE_WRITErÚ _compressorÚ
isinstanceÚstrÚbytesÚosÚPathLikeÚ
_builtin_openÚhasattrÚ TypeErrorÚ _compressionÚDecompressReaderrÚOSErrorÚioÚBufferedReaderÚ_bufferÚ_pos)ÚselfÚfilenameÚmoderÚ mode_codeÚraws ú?C:\Users\RCi\AppData\Local\Programs\Python\Python312\Lib\bz2.pyÚ__init__zBZ2File.__init__%s^€ð$ˆŒØˆŒ
Ü!ˆŒ
à�]Ô' aÒ'ÜÐDÓEÐ Eð(ÜÐDÓEÐ Eà �?Ñ "؈DÜ"‰IØ
�[Ñ
؈DÜ#ˆIÜ,¨]Ó;ˆDÕ Ø
�[Ñ
؈DÜ#ˆIÜ,¨]Ó;ˆDÕ Ø
�[Ñ
؈DÜ#ˆIÜ,¨]Ó;ˆDÕ å±4Ð9Ó:Ð :ä �h¤¤e¬R¯[©[Ð 9Ô :Ü$ X¨tÓ4ˆDŒHØ ˆDŒMØ"ˆD�JÜ
�X˜vÔ
&¬'°(¸GÔ*D؈DŒHØ"ˆD�JäÐTÓUÐ Uà �:‰:œÒ #Ü×/Ñ/°·±Ü´ô9ˆCä×,Ñ,¨SÓ1ˆD�LàˆD�IócóÞ—|jtk(ry |jtk(r|jj «nM|jt
k(r:|j j|jj««d|_ |jr|j j «d|_d|_
t|_d|_y#d|_d|_
t|_d|_wxYw# |jr|j j «d|_d|_
t|_d|_w#d|_d|_
t|_d|_wxYwxYw)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 rr"r2Úcloser#rrr$Úflushr©r4s r9r=z
BZ2File.closeas€ð �:‰:œÒ %Ø ð $Ø�z‰zœZÒ'Ø— ‘ ×"Ñ"Õ$Ø—‘œ{Ò*Ø—‘—‘˜t×/Ñ/×5Ñ5Ó7Ô8Ø#'�Ô ð
$Ø—=’=Ø—H‘H—N‘NÔ$à�”Ø %�”
Ü)�”
Ø#�• øð �”Ø %�”
Ü)�”
Ø#�• ûð
$Ø—=’=Ø—H‘H—N‘NÔ$à�”Ø %�”
Ü)�”
Ø#�• øð �”Ø %�”
Ü)�”
Ø#�• ýs0–A;C>Â&CÃ"C;Ã>E,Ä&EÄ&!E,Å"E)Å)E,có(—|jtk(S)zTrue if this file is closed.)r rr?s r9ÚclosedzBZ2File.closedys€ð�z‰zœ\Ñ)Ð)r;cóV—|j«|jj«S)z3Return the file descriptor for the underlying file.)Ú_check_not_closedrÚfilenor?s r9rDzBZ2File.fileno~s€à ×ÑÔ Ø�x‰x�‰Ó Ð r;cóZ—|j«xr|jj«S)z)Return whether the file supports seeking.)Úreadabler2Úseekabler?s r9rGzBZ2File.seekableƒs €à�}‰}‹Ò: 4§<¡<×#8Ñ#8Ó#:Ð:r;cóH—|j«|jtk(S)z/Return whether the file was opened for reading.)rCr r"r?s r9rFzBZ2File.readable‡s€à ×ÑÔ Ø�z‰zœZÑ'Ð'r;cóH—|j«|jtk(S)z/Return whether the file was opened for writing.)rCr r#r?s r9ÚwritablezBZ2File.writableŒs€à ×ÑÔ Ø�z‰zœ[Ñ(Ð(r;cóX—|j«|jj|«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)r4Úns r9rMz BZ2File.peek‘s'€ð
×ÑÔð�|‰|× Ñ  Ó#Ð#r;cóX—|j«|jj|«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.
)rLr2r©r4Úsizes r9rz BZ2File.read�s%€ð
×ÑÔØ�|‰|× Ñ  Ó&Ð&r;có‚—|j«|dkrtj}|jj |«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)rLr0ÚDEFAULT_BUFFER_SIZEr2Úread1rPs r9rTz
BZ2File.read1¦s7€ð
×ÑÔØ �!Š8Ü×)Ñ)ˆDØ�|‰|×!Ñ! $Ó'Ð'r;cóX—|j«|jj|«S)zRRead bytes into b.
Returns the number of bytes read (0 for EOF).
)rLr2Úreadinto)r4Úbs r9rVzBZ2File.readinto²s%€ð
×ÑÔØ�|‰|×$Ñ$ QÓ'Ð'r;cóÆ—t|t«s't|d«s td«‚|j «}|j «|j 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.
Ú __index__úInteger argument expected)r%Úintr+r,rYrLr2ÚreadlinerPs r9r\zBZ2File.readlineºsQ€ô˜$¤Ô$ܘ4 Ô-ÜÐ ;Ó<Ð<Ø—>‘>Ó#ˆDØ ×ÑÔØ�|‰|×$Ñ$ TÓ*Ð*r;cóÆ—t|t«s't|d«s td«‚|j «}|j «|j j|«S)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.
rYrZ)r%r[r+r,rYrLr2Ú readlinesrPs r9r^zBZ2File.readlinesÈsQ€ô˜$¤Ô$ܘ4 Ô-ÜÐ ;Ó<Ð<Ø—>‘>Ó#ˆDØ ×ÑÔØ�|‰|×%Ñ% dÓ+Ð+r;có.—|j«t|ttf«r t |«}nt |«}|j }|jj|«}|jj|«|xj|z
c_ |S)aWrite a byte string to the file.
Returns the number of uncompressed bytes written, which is
always the length of data in bytes. Note that due to buffering,
the file on disk may not reflect the data written until close()
is called.
) Ú_check_can_writer%r'Ú bytearrayÚlenÚ
memoryviewÚnbytesr$rrrr3)r4ÚdataÚlengthÚ
compresseds r9rz
BZ2File.writeÖsv€ð
×ÑÔÜ �dœU¤IÐ.Ô /ܘ“Y‰Fô˜dÓ#ˆDØ—[‘[ˆFà×%Ñ%×.Ñ.¨tÓ4ˆ
Ø �‰�‰�zÔ"Ø � Š �VÑ� ؈
r;cóB—tjj||«S)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.
)r-Ú
BaseStreamÚ
writelines)r4Úseqs r9rjzBZ2File.writelinesës€ô×&Ñ&×1Ñ1°$¸Ó<Ð<r;cóZ—|j«|jj||«S)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.
)Ú_check_can_seekr2Úseek)r4ÚoffsetÚwhences r9rnz BZ2File.seekõs'€ð
×ÑÔØ�|‰|× Ñ  ¨Ó0Ð0r;có”—|j«|jtk(r|jj «S|j
S)z!Return the current file position.)rCr r"r2Útellr3r?s r9rrz BZ2File.tells7€à ×ÑÔ Ø �:‰:œÒ #Ø—<‘<×$Ñ$Ó&Ð &Ø�y‰yÐr;N)r)r)éÿÿÿÿ)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r:r=ÚpropertyrArDrGrFrJrMrrTrVr\r^rrjr0ÚSEEK_SETrnrr©r;r9rrs|„ñð:¸Aô:òx$ð0ñ*óð*ò!ò
;ò(ò
)ó