/
opt
/
imh
/
python3.13
/
lib
/
python3.13
/
/opt/imh/python3.13/lib/python3.13
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.13-x86_64-linux-gnu/
-
0755
rm
ctypes/
-
0755
rm
curses/
-
0755
rm
dbm/
-
0755
rm
email/
-
0755
rm
encodings/
-
0755
rm
ensurepip/
-
0755
rm
html/
-
0755
rm
http/
-
0755
rm
idlelib/
-
0755
rm
importlib/
-
0755
rm
json/
-
0755
rm
lib-dynload/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
pathlib/
-
0755
rm
pydoc_data/
-
0755
rm
re/
-
0755
rm
site-packages/
-
0755
rm
sqlite3/
-
0755
rm
sysconfig/
-
0755
rm
tkinter/
-
0755
rm
tomllib/
-
0755
rm
turtledemo/
-
0755
rm
unittest/
-
0755
rm
urllib/
-
0755
rm
venv/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
xmlrpc/
-
0755
rm
zipfile/
-
0755
rm
zoneinfo/
-
0755
rm
_pyrepl/
-
0755
rm
__phello__/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
6538
0644
edit
dl
rm
antigravity.py
500
0644
edit
dl
rm
argparse.py
101661
0644
edit
dl
rm
ast.py
65339
0644
edit
dl
rm
base64.py
21630
0755
edit
dl
rm
bdb.py
35343
0644
edit
dl
rm
bisect.py
3423
0644
edit
dl
rm
bz2.py
11969
0644
edit
dl
rm
calendar.py
26077
0644
edit
dl
rm
cmd.py
15316
0644
edit
dl
rm
code.py
13170
0644
edit
dl
rm
codecs.py
36978
0644
edit
dl
rm
codeop.py
5828
0644
edit
dl
rm
colorsys.py
4062
0644
edit
dl
rm
compileall.py
20665
0644
edit
dl
rm
configparser.py
53831
0644
edit
dl
rm
contextlib.py
27801
0644
edit
dl
rm
contextvars.py
129
0644
edit
dl
rm
copy.py
8975
0644
edit
dl
rm
copyreg.py
7614
0644
edit
dl
rm
cProfile.py
6624
0755
edit
dl
rm
csv.py
19178
0644
edit
dl
rm
dataclasses.py
64545
0644
edit
dl
rm
datetime.py
268
0644
edit
dl
rm
decimal.py
2798
0644
edit
dl
rm
difflib.py
83367
0644
edit
dl
rm
dis.py
40962
0644
edit
dl
rm
doctest.py
109414
0644
edit
dl
rm
enum.py
85593
0644
edit
dl
rm
filecmp.py
10652
0644
edit
dl
rm
fileinput.py
15717
0644
edit
dl
rm
fnmatch.py
6180
0644
edit
dl
rm
fractions.py
40090
0644
edit
dl
rm
ftplib.py
34735
0644
edit
dl
rm
functools.py
39123
0644
edit
dl
rm
genericpath.py
6247
0644
edit
dl
rm
getopt.py
7488
0644
edit
dl
rm
getpass.py
6233
0644
edit
dl
rm
gettext.py
21534
0644
edit
dl
rm
glob.py
19720
0644
edit
dl
rm
graphlib.py
9648
0644
edit
dl
rm
gzip.py
24633
0644
edit
dl
rm
hashlib.py
9446
0644
edit
dl
rm
heapq.py
23024
0644
edit
dl
rm
hmac.py
7716
0644
edit
dl
rm
imaplib.py
54040
0644
edit
dl
rm
inspect.py
128276
0644
edit
dl
rm
io.py
3582
0644
edit
dl
rm
ipaddress.py
81635
0644
edit
dl
rm
keyword.py
1073
0644
edit
dl
rm
LICENSE.txt
13809
0644
edit
dl
rm
linecache.py
7284
0644
edit
dl
rm
locale.py
79033
0644
edit
dl
rm
lzma.py
13399
0644
edit
dl
rm
mailbox.py
81644
0644
edit
dl
rm
mimetypes.py
23851
0644
edit
dl
rm
modulefinder.py
23792
0644
edit
dl
rm
netrc.py
7031
0644
edit
dl
rm
ntpath.py
32806
0644
edit
dl
rm
nturl2path.py
2374
0644
edit
dl
rm
numbers.py
11769
0644
edit
dl
rm
opcode.py
2825
0644
edit
dl
rm
operator.py
10980
0644
edit
dl
rm
optparse.py
60369
0644
edit
dl
rm
os.py
41627
0644
edit
dl
rm
pdb.py
90925
0755
edit
dl
rm
pickle.py
66957
0644
edit
dl
rm
pickletools.py
94052
0644
edit
dl
rm
pkgutil.py
18281
0644
edit
dl
rm
platform.py
47345
0755
edit
dl
rm
plistlib.py
29794
0644
edit
dl
rm
poplib.py
14604
0644
edit
dl
rm
posixpath.py
18360
0644
edit
dl
rm
pprint.py
24158
0644
edit
dl
rm
profile.py
23140
0755
edit
dl
rm
pstats.py
29296
0644
edit
dl
rm
pty.py
6137
0644
edit
dl
rm
pyclbr.py
11396
0644
edit
dl
rm
pydoc.py
110064
0755
edit
dl
rm
py_compile.py
7837
0644
edit
dl
rm
queue.py
13455
0644
edit
dl
rm
quopri.py
7184
0755
edit
dl
rm
random.py
37006
0644
edit
dl
rm
reprlib.py
8068
0644
edit
dl
rm
rlcompleter.py
7918
0644
edit
dl
rm
runpy.py
12885
0644
edit
dl
rm
sched.py
6351
0644
edit
dl
rm
secrets.py
1984
0644
edit
dl
rm
selectors.py
19457
0644
edit
dl
rm
shelve.py
8810
0644
edit
dl
rm
shlex.py
13353
0644
edit
dl
rm
shutil.py
57463
0644
edit
dl
rm
signal.py
2495
0644
edit
dl
rm
site.py
25568
0644
edit
dl
rm
smtplib.py
43532
0755
edit
dl
rm
socket.py
37759
0644
edit
dl
rm
socketserver.py
28065
0644
edit
dl
rm
sre_compile.py
231
0644
edit
dl
rm
sre_constants.py
232
0644
edit
dl
rm
sre_parse.py
229
0644
edit
dl
rm
ssl.py
52706
0644
edit
dl
rm
stat.py
6147
0644
edit
dl
rm
statistics.py
61831
0644
edit
dl
rm
string.py
11786
0644
edit
dl
rm
stringprep.py
12917
0644
edit
dl
rm
struct.py
257
0644
edit
dl
rm
subprocess.py
89486
0644
edit
dl
rm
symtable.py
14207
0644
edit
dl
rm
tabnanny.py
11532
0755
edit
dl
rm
tarfile.py
114239
0755
edit
dl
rm
tempfile.py
32406
0644
edit
dl
rm
textwrap.py
19939
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
55300
0644
edit
dl
rm
timeit.py
13464
0755
edit
dl
rm
token.py
2489
0644
edit
dl
rm
tokenize.py
21568
0644
edit
dl
rm
trace.py
29714
0755
edit
dl
rm
traceback.py
66524
0644
edit
dl
rm
tracemalloc.py
18047
0644
edit
dl
rm
tty.py
2035
0644
edit
dl
rm
turtle.py
145215
0644
edit
dl
rm
types.py
11207
0644
edit
dl
rm
typing.py
132718
0644
edit
dl
rm
uuid.py
29458
0644
edit
dl
rm
warnings.py
26948
0644
edit
dl
rm
wave.py
23254
0644
edit
dl
rm
weakref.py
21513
0644
edit
dl
rm
webbrowser.py
24285
0755
edit
dl
rm
zipapp.py
8618
0644
edit
dl
rm
zipimport.py
32890
0644
edit
dl
rm
_aix_support.py
4021
0644
edit
dl
rm
_android_support.py
6895
0644
edit
dl
rm
_apple_support.py
2256
0644
edit
dl
rm
_collections_abc.py
32264
0644
edit
dl
rm
_colorize.py
2848
0644
edit
dl
rm
_compat_pickle.py
8735
0644
edit
dl
rm
_compression.py
5681
0644
edit
dl
rm
_ios_support.py
2672
0644
edit
dl
rm
_markupbase.py
14653
0644
edit
dl
rm
_opcode_metadata.py
9265
0644
edit
dl
rm
_osx_support.py
22023
0644
edit
dl
rm
_pydatetime.py
91983
0644
edit
dl
rm
_pydecimal.py
227286
0644
edit
dl
rm
_pyio.py
93693
0644
edit
dl
rm
_pylong.py
11830
0644
edit
dl
rm
_py_abc.py
6189
0644
edit
dl
rm
_sitebuiltins.py
3128
0644
edit
dl
rm
_strptime.py
34734
0644
edit
dl
rm
_sysconfigdata__linux_x86_64-linux-gnu.py
45021
0644
edit
dl
rm
_threading_local.py
4363
0644
edit
dl
rm
_weakrefset.py
5893
0644
edit
dl
rm
__future__.py
5218
0644
edit
dl
rm
__hello__.py
227
0644
edit
dl
rm
Edit:
/opt/imh/python3.13/lib/python3.13/bz2.py
(11969B)
"""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 # Value 0 no longer used _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 = None 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.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._buffer = None @property def closed(self): """True if this file is closed.""" return self._fp is None @property def name(self): self._check_not_closed() return self._fp.name @property def mode(self): return 'wb' if self._mode == _MODE_WRITE else 'rb' 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