/
usr
/
lib
/
python3.10
/
/usr/lib/python3.10
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.10-x86_64-linux-gnu/
-
0755
rm
ctypes/
-
0755
rm
curses/
-
0755
rm
dbm/
-
0755
rm
distutils/
-
0755
rm
email/
-
0755
rm
encodings/
-
0755
rm
html/
-
0755
rm
http/
-
0755
rm
importlib/
-
0755
rm
json/
-
0755
rm
lib-dynload/
-
0755
rm
lib2to3/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
pydoc_data/
-
0755
rm
sqlite3/
-
0755
rm
test/
-
0755
rm
unittest/
-
0755
rm
urllib/
-
0755
rm
venv/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
xmlrpc/
-
0755
rm
zoneinfo/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
6522
0644
edit
dl
rm
aifc.py
32605
0644
edit
dl
rm
antigravity.py
500
0644
edit
dl
rm
argparse.py
98839
0644
edit
dl
rm
ast.py
59900
0644
edit
dl
rm
asynchat.py
11520
0644
edit
dl
rm
asyncore.py
20268
0644
edit
dl
rm
base64.py
20846
0755
edit
dl
rm
bdb.py
32396
0644
edit
dl
rm
binhex.py
14784
0644
edit
dl
rm
bisect.py
3135
0644
edit
dl
rm
bz2.py
11847
0644
edit
dl
rm
calendar.py
24575
0644
edit
dl
rm
cgi.py
34099
0755
edit
dl
rm
cgitb.py
12096
0644
edit
dl
rm
chunk.py
5435
0644
edit
dl
rm
cmd.py
14860
0644
edit
dl
rm
code.py
10622
0644
edit
dl
rm
codecs.py
36714
0644
edit
dl
rm
codeop.py
5609
0644
edit
dl
rm
colorsys.py
4017
0644
edit
dl
rm
compileall.py
20252
0644
edit
dl
rm
configparser.py
54612
0644
edit
dl
rm
contextlib.py
25882
0644
edit
dl
rm
contextvars.py
129
0644
edit
dl
rm
copy.py
8681
0644
edit
dl
rm
copyreg.py
7426
0644
edit
dl
rm
cProfile.py
6347
0755
edit
dl
rm
crypt.py
3848
0644
edit
dl
rm
csv.py
16030
0644
edit
dl
rm
dataclasses.py
56390
0644
edit
dl
rm
datetime.py
88086
0644
edit
dl
rm
decimal.py
320
0644
edit
dl
rm
difflib.py
83308
0644
edit
dl
rm
dis.py
20020
0644
edit
dl
rm
doctest.py
105143
0644
edit
dl
rm
enum.py
39831
0644
edit
dl
rm
filecmp.py
10178
0644
edit
dl
rm
fileinput.py
16442
0644
edit
dl
rm
fnmatch.py
6713
0644
edit
dl
rm
fractions.py
28242
0644
edit
dl
rm
ftplib.py
36001
0644
edit
dl
rm
functools.py
38076
0644
edit
dl
rm
genericpath.py
4975
0644
edit
dl
rm
getopt.py
7489
0644
edit
dl
rm
getpass.py
5990
0644
edit
dl
rm
gettext.py
27693
0644
edit
dl
rm
glob.py
7888
0644
edit
dl
rm
graphlib.py
9573
0644
edit
dl
rm
gzip.py
21849
0644
edit
dl
rm
hashlib.py
10229
0644
edit
dl
rm
heapq.py
22877
0644
edit
dl
rm
hmac.py
7717
0644
edit
dl
rm
imaplib.py
54866
0644
edit
dl
rm
imghdr.py
3808
0644
edit
dl
rm
imp.py
10591
0644
edit
dl
rm
inspect.py
124378
0644
edit
dl
rm
io.py
4196
0644
edit
dl
rm
ipaddress.py
77780
0644
edit
dl
rm
keyword.py
1061
0644
edit
dl
rm
LICENSE.txt
13936
0644
edit
dl
rm
linecache.py
5690
0644
edit
dl
rm
locale.py
78128
0644
edit
dl
rm
lzma.py
13277
0644
edit
dl
rm
mailbox.py
78794
0644
edit
dl
rm
mailcap.py
9116
0644
edit
dl
rm
mimetypes.py
22539
0644
edit
dl
rm
modulefinder.py
24401
0644
edit
dl
rm
netrc.py
5747
0644
edit
dl
rm
nntplib.py
41023
0644
edit
dl
rm
ntpath.py
27561
0644
edit
dl
rm
nturl2path.py
2887
0644
edit
dl
rm
numbers.py
10348
0644
edit
dl
rm
opcode.py
5902
0644
edit
dl
rm
operator.py
10751
0644
edit
dl
rm
optparse.py
60369
0644
edit
dl
rm
os.py
39557
0644
edit
dl
rm
pathlib.py
49575
0644
edit
dl
rm
pdb.py
63225
0755
edit
dl
rm
pickle.py
64949
0644
edit
dl
rm
pickletools.py
93486
0644
edit
dl
rm
pipes.py
8914
0644
edit
dl
rm
pkgutil.py
24576
0644
edit
dl
rm
platform.py
42022
0755
edit
dl
rm
plistlib.py
28592
0644
edit
dl
rm
poplib.py
15198
0644
edit
dl
rm
posixpath.py
16123
0644
edit
dl
rm
pprint.py
24444
0644
edit
dl
rm
profile.py
22883
0755
edit
dl
rm
pstats.py
29326
0644
edit
dl
rm
pty.py
5213
0644
edit
dl
rm
pyclbr.py
11396
0644
edit
dl
rm
pydoc.py
109884
0755
edit
dl
rm
py_compile.py
7878
0644
edit
dl
rm
queue.py
11496
0644
edit
dl
rm
quopri.py
7267
0755
edit
dl
rm
random.py
33221
0644
edit
dl
rm
re.py
15860
0644
edit
dl
rm
reprlib.py
5267
0644
edit
dl
rm
rlcompleter.py
7817
0644
edit
dl
rm
runpy.py
13111
0644
edit
dl
rm
sched.py
6351
0644
edit
dl
rm
secrets.py
2036
0644
edit
dl
rm
selectors.py
19536
0644
edit
dl
rm
shelve.py
8560
0644
edit
dl
rm
shlex.py
13501
0644
edit
dl
rm
shutil.py
54572
0644
edit
dl
rm
signal.py
2438
0644
edit
dl
rm
site.py
23667
0644
edit
dl
rm
sitecustomize.py
155
0644
edit
dl
rm
smtpd.py
35165
0755
edit
dl
rm
smtplib.py
45418
0755
edit
dl
rm
sndhdr.py
7099
0644
edit
dl
rm
socket.py
36785
0644
edit
dl
rm
socketserver.py
27296
0644
edit
dl
rm
sre_compile.py
27973
0644
edit
dl
rm
sre_constants.py
7177
0644
edit
dl
rm
sre_parse.py
40779
0644
edit
dl
rm
ssl.py
53725
0644
edit
dl
rm
stat.py
5485
0644
edit
dl
rm
statistics.py
43205
0644
edit
dl
rm
string.py
10566
0644
edit
dl
rm
stringprep.py
12917
0644
edit
dl
rm
struct.py
257
0644
edit
dl
rm
subprocess.py
84917
0644
edit
dl
rm
sunau.py
18158
0644
edit
dl
rm
symtable.py
10217
0644
edit
dl
rm
sysconfig.py
29398
0644
edit
dl
rm
tabnanny.py
11299
0755
edit
dl
rm
tarfile.py
108332
0755
edit
dl
rm
telnetlib.py
23254
0644
edit
dl
rm
tempfile.py
34567
0644
edit
dl
rm
textwrap.py
19772
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
57200
0644
edit
dl
rm
timeit.py
13495
0755
edit
dl
rm
token.py
2386
0644
edit
dl
rm
tokenize.py
25921
0644
edit
dl
rm
trace.py
29215
0755
edit
dl
rm
traceback.py
26222
0644
edit
dl
rm
tracemalloc.py
18047
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
turtle.py
143760
0644
edit
dl
rm
types.py
10117
0644
edit
dl
rm
typing.py
92557
0644
edit
dl
rm
uu.py
7300
0755
edit
dl
rm
uuid.py
27500
0644
edit
dl
rm
warnings.py
19688
0644
edit
dl
rm
wave.py
18004
0644
edit
dl
rm
weakref.py
21560
0644
edit
dl
rm
webbrowser.py
24739
0755
edit
dl
rm
xdrlib.py
5913
0644
edit
dl
rm
zipapp.py
7535
0644
edit
dl
rm
zipfile.py
90851
0644
edit
dl
rm
zipimport.py
30891
0644
edit
dl
rm
_aix_support.py
3270
0644
edit
dl
rm
_bootsubprocess.py
2675
0644
edit
dl
rm
_collections_abc.py
32284
0644
edit
dl
rm
_compat_pickle.py
8749
0644
edit
dl
rm
_compression.py
5681
0644
edit
dl
rm
_distutils_system_mod.py
6312
0644
edit
dl
rm
_markupbase.py
14653
0644
edit
dl
rm
_osx_support.py
21787
0644
edit
dl
rm
_pydecimal.py
228676
0644
edit
dl
rm
_pyio.py
94467
0644
edit
dl
rm
_py_abc.py
6189
0644
edit
dl
rm
_sitebuiltins.py
3128
0644
edit
dl
rm
_strptime.py
25277
0644
edit
dl
rm
_sysconfigdata__linux_x86_64-linux-gnu.py
27484
0644
edit
dl
rm
_sysconfigdata__x86_64-linux-gnu.py
27484
0644
edit
dl
rm
_threading_local.py
7220
0644
edit
dl
rm
_weakrefset.py
5923
0644
edit
dl
rm
__future__.py
5155
0644
edit
dl
rm
__phello__.foo.py
64
0644
edit
dl
rm
Edit:
/usr/lib/python3.10/bz2.py
(11847B)
"""Interface to the libbzip2 compression library. This module provides a file interface, classes for incremental (de)compression, and functions for one-shot (de)compression. """ __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"] __author__ = "Nadeem Vawda <nadeem.vawda@gmail.com>" from builtins import open as _builtin_open import io import os import _compression from _bz2 import BZ2Compressor, BZ2Decompressor _MODE_CLOSED = 0 _MODE_READ = 1 # Value 2 no longer used _MODE_WRITE = 3 class BZ2File(_compression.BaseStream): """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. """ def __init__(self, filename, mode="r", *, compresslevel=9): """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. """ self._fp = None self._closefp = False self._mode = _MODE_CLOSED if not (1 <= compresslevel <= 9): raise ValueError("compresslevel must be between 1 and 9") if mode in ("", "r", "rb"): mode = "rb" mode_code = _MODE_READ elif mode in ("w", "wb"): mode = "wb" mode_code = _MODE_WRITE self._compressor = BZ2Compressor(compresslevel) elif mode in ("x", "xb"): mode = "xb" mode_code = _MODE_WRITE self._compressor = BZ2Compressor(compresslevel) elif mode in ("a", "ab"): mode = "ab" mode_code = _MODE_WRITE self._compressor = BZ2Compressor(compresslevel) else: raise ValueError("Invalid mode: %r" % (mode,)) if isinstance(filename, (str, bytes, os.PathLike)): self._fp = _builtin_open(filename, mode) self._closefp = True self._mode = mode_code elif hasattr(filename, "read") or hasattr(filename, "write"): self._fp = filename self._mode = mode_code else: raise TypeError("filename must be a str, bytes, file or PathLike object") if self._mode == _MODE_READ: raw = _compression.DecompressReader(self._fp, BZ2Decompressor, trailing_error=OSError) self._buffer = io.BufferedReader(raw) else: self._pos = 0 def close(self): """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. """ if self._mode == _MODE_CLOSED: return try: if self._mode == _MODE_READ: self._buffer.close() elif self._mode == _MODE_WRITE: self._fp.write(self._compressor.flush()) self._compressor = None finally: try: if self._closefp: self._fp.close() finally: self._fp = None self._closefp = False self._mode = _MODE_CLOSED self._buffer = None @property def closed(self): """True if this file is closed.""" return self._mode == _MODE_CLOSED def fileno(self): """Return the file descriptor for the underlying file.""" self._check_not_closed() return self._fp.fileno() def seekable(self): """Return whether the file supports seeking.""" return self.readable() and self._buffer.seekable() def readable(self): """Return whether the file was opened for reading.""" self._check_not_closed() return self._mode == _MODE_READ def writable(self): """Return whether the file was opened for writing.""" self._check_not_closed() return self._mode == _MODE_WRITE def peek(self, n=0): """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. """ self._check_can_read() # Relies on the undocumented fact that BufferedReader.peek() # always returns at least one byte (except at EOF), independent # of the value of n return self._buffer.peek(n) def read(self, size=-1): """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. """ self._check_can_read() return self._buffer.read(size) def read1(self, size=-1): """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. """ self._check_can_read() if size < 0: size = io.DEFAULT_BUFFER_SIZE return self._buffer.read1(size) def readinto(self, b): """Read bytes into b. Returns the number of bytes read (0 for EOF). """ self._check_can_read() return self._buffer.readinto(b) def readline(self, size=-1): """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. """ if not isinstance(size, int): if not hasattr(size, "__index__"): raise TypeError("Integer argument expected") size = size.__index__() self._check_can_read() return self._buffer.readline(size) def readlines(self, size=-1): """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. """ if not isinstance(size, int): if not hasattr(size, "__index__"): raise TypeError("Integer argument expected") size = size.__index__() self._check_can_read() return self._buffer.readlines(size) def write(self, data): """Write 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. """ self._check_can_write() if isinstance(data, (bytes, bytearray)): length = len(data) else: # accept any data that supports the buffer protocol data = memoryview(data) length = data.nbytes compressed = self._compressor.compress(data) self._fp.write(compressed) self._pos += length return length def writelines(self, seq): """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. """ return _compression.BaseStream.writelines(self, seq) def seek(self, offset, whence=io.SEEK_SET): """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. """ self._check_can_seek() return self._buffer.seek(offset, whence) def tell(self): """Return the current file position.""" self._check_not_closed() if self._mode == _MODE_READ: return self._buffer.tell() return self._pos def open(filename, mode="rb", compresslevel=9, encoding=None, errors=None, newline=None): """Open a bzip2-compressed file in binary or text mode. The filename argument can be an actual filename (a str, bytes, or PathLike 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). """ if "t" in mode: if "b" in mode: raise ValueError("Invalid mode: %r" % (mode,)) else: if encoding is not None: raise ValueError("Argument 'encoding' not supported in binary mode") if errors is not None: raise ValueError("Argument 'errors' not supported in binary mode") if newline is not None: raise ValueError("Argument 'newline' not supported in binary mode") bz_mode = mode.replace("t", "") binary_file = BZ2File(filename, bz_mode, compresslevel=compresslevel) if "t" in mode: encoding = io.text_encoding(encoding) return io.TextIOWrapper(binary_file, encoding, errors, newline) else: return binary_file def compress(data, compresslevel=9): """Compress a block of data. compresslevel, if given, must be a number between 1 and 9. For incremental compression, use a BZ2Compressor object instead. """ comp = BZ2Compressor(compresslevel) return comp.compress(data) + comp.flush() def decompress(data): """Decompress a block of data. For incremental decompression, use a BZ2Decompressor object instead. """ results = [] while data: decomp = BZ2Decompressor() try: res = decomp.decompress(data) except OSError: if results: break # Leftover data is not a valid bzip2 stream; ignore it. else: raise # Error on the first iteration; bail out. results.append(res) if not decomp.eof: raise ValueError("Compressed data ended before the " "end-of-stream marker was reached") data = decomp.unused_data return b"".join(results)
Save
cmd:
run