/usr/lib/python3.10
NameSizeModeActions
asyncio/-0755rm
collections/-0755rm
concurrent/-0755rm
config-3.10-x86_64-linux-gnu/-0755rm
ctypes/-0755rm
curses/-0755rm
dbm/-0755rm
distutils/-0755rm
email/-0755rm
encodings/-0755rm
html/-0755rm
http/-0755rm
importlib/-0755rm
json/-0755rm
lib-dynload/-0755rm
lib2to3/-0755rm
logging/-0755rm
multiprocessing/-0755rm
pydoc_data/-0755rm
sqlite3/-0755rm
test/-0755rm
unittest/-0755rm
urllib/-0755rm
venv/-0755rm
wsgiref/-0755rm
xml/-0755rm
xmlrpc/-0755rm
zoneinfo/-0755rm
__pycache__/-0755rm
abc.py65220644editdlrm
aifc.py326050644editdlrm
antigravity.py5000644editdlrm
argparse.py988390644editdlrm
ast.py599000644editdlrm
asynchat.py115200644editdlrm
asyncore.py202680644editdlrm
base64.py208460755editdlrm
bdb.py323960644editdlrm
binhex.py147840644editdlrm
bisect.py31350644editdlrm
bz2.py118470644editdlrm
calendar.py245750644editdlrm
cgi.py340990755editdlrm
cgitb.py120960644editdlrm
chunk.py54350644editdlrm
cmd.py148600644editdlrm
code.py106220644editdlrm
codecs.py367140644editdlrm
codeop.py56090644editdlrm
colorsys.py40170644editdlrm
compileall.py202520644editdlrm
configparser.py546120644editdlrm
contextlib.py258820644editdlrm
contextvars.py1290644editdlrm
copy.py86810644editdlrm
copyreg.py74260644editdlrm
cProfile.py63470755editdlrm
crypt.py38480644editdlrm
csv.py160300644editdlrm
dataclasses.py563900644editdlrm
datetime.py880860644editdlrm
decimal.py3200644editdlrm
difflib.py833080644editdlrm
dis.py200200644editdlrm
doctest.py1051430644editdlrm
enum.py398310644editdlrm
filecmp.py101780644editdlrm
fileinput.py164420644editdlrm
fnmatch.py67130644editdlrm
fractions.py282420644editdlrm
ftplib.py360010644editdlrm
functools.py380760644editdlrm
genericpath.py49750644editdlrm
getopt.py74890644editdlrm
getpass.py59900644editdlrm
gettext.py276930644editdlrm
glob.py78880644editdlrm
graphlib.py95730644editdlrm
gzip.py218490644editdlrm
hashlib.py102290644editdlrm
heapq.py228770644editdlrm
hmac.py77170644editdlrm
imaplib.py548660644editdlrm
imghdr.py38080644editdlrm
imp.py105910644editdlrm
inspect.py1243780644editdlrm
io.py41960644editdlrm
ipaddress.py777800644editdlrm
keyword.py10610644editdlrm
LICENSE.txt139360644editdlrm
linecache.py56900644editdlrm
locale.py781280644editdlrm
lzma.py132770644editdlrm
mailbox.py787940644editdlrm
mailcap.py91160644editdlrm
mimetypes.py225390644editdlrm
modulefinder.py244010644editdlrm
netrc.py57470644editdlrm
nntplib.py410230644editdlrm
ntpath.py275610644editdlrm
nturl2path.py28870644editdlrm
numbers.py103480644editdlrm
opcode.py59020644editdlrm
operator.py107510644editdlrm
optparse.py603690644editdlrm
os.py395570644editdlrm
pathlib.py495750644editdlrm
pdb.py632250755editdlrm
pickle.py649490644editdlrm
pickletools.py934860644editdlrm
pipes.py89140644editdlrm
pkgutil.py245760644editdlrm
platform.py420220755editdlrm
plistlib.py285920644editdlrm
poplib.py151980644editdlrm
posixpath.py161230644editdlrm
pprint.py244440644editdlrm
profile.py228830755editdlrm
pstats.py293260644editdlrm
pty.py52130644editdlrm
pyclbr.py113960644editdlrm
pydoc.py1098840755editdlrm
py_compile.py78780644editdlrm
queue.py114960644editdlrm
quopri.py72670755editdlrm
random.py332210644editdlrm
re.py158600644editdlrm
reprlib.py52670644editdlrm
rlcompleter.py78170644editdlrm
runpy.py131110644editdlrm
sched.py63510644editdlrm
secrets.py20360644editdlrm
selectors.py195360644editdlrm
shelve.py85600644editdlrm
shlex.py135010644editdlrm
shutil.py545720644editdlrm
signal.py24380644editdlrm
site.py236670644editdlrm
sitecustomize.py1550644editdlrm
smtpd.py351650755editdlrm
smtplib.py454180755editdlrm
sndhdr.py70990644editdlrm
socket.py367850644editdlrm
socketserver.py272960644editdlrm
sre_compile.py279730644editdlrm
sre_constants.py71770644editdlrm
sre_parse.py407790644editdlrm
ssl.py537250644editdlrm
stat.py54850644editdlrm
statistics.py432050644editdlrm
string.py105660644editdlrm
stringprep.py129170644editdlrm
struct.py2570644editdlrm
subprocess.py849170644editdlrm
sunau.py181580644editdlrm
symtable.py102170644editdlrm
sysconfig.py293980644editdlrm
tabnanny.py112990755editdlrm
tarfile.py1083320755editdlrm
telnetlib.py232540644editdlrm
tempfile.py345670644editdlrm
textwrap.py197720644editdlrm
this.py10030644editdlrm
threading.py572000644editdlrm
timeit.py134950755editdlrm
token.py23860644editdlrm
tokenize.py259210644editdlrm
trace.py292150755editdlrm
traceback.py262220644editdlrm
tracemalloc.py180470644editdlrm
tty.py8790644editdlrm
turtle.py1437600644editdlrm
types.py101170644editdlrm
typing.py925570644editdlrm
uu.py73000755editdlrm
uuid.py275000644editdlrm
warnings.py196880644editdlrm
wave.py180040644editdlrm
weakref.py215600644editdlrm
webbrowser.py247390755editdlrm
xdrlib.py59130644editdlrm
zipapp.py75350644editdlrm
zipfile.py908510644editdlrm
zipimport.py308910644editdlrm
_aix_support.py32700644editdlrm
_bootsubprocess.py26750644editdlrm
_collections_abc.py322840644editdlrm
_compat_pickle.py87490644editdlrm
_compression.py56810644editdlrm
_distutils_system_mod.py63120644editdlrm
_markupbase.py146530644editdlrm
_osx_support.py217870644editdlrm
_pydecimal.py2286760644editdlrm
_pyio.py944670644editdlrm
_py_abc.py61890644editdlrm
_sitebuiltins.py31280644editdlrm
_strptime.py252770644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.py274840644editdlrm
_sysconfigdata__x86_64-linux-gnu.py274840644editdlrm
_threading_local.py72200644editdlrm
_weakrefset.py59230644editdlrm
__future__.py51550644editdlrm
__phello__.foo.py640644editdlrm
Edit: /usr/lib/python3.10/lzma.py (13277B)
"""Interface 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. """ __all__ = [ "CHECK_NONE", "CHECK_CRC32", "CHECK_CRC64", "CHECK_SHA256", "CHECK_ID_MAX", "CHECK_UNKNOWN", "FILTER_LZMA1", "FILTER_LZMA2", "FILTER_DELTA", "FILTER_X86", "FILTER_IA64", "FILTER_ARM", "FILTER_ARMTHUMB", "FILTER_POWERPC", "FILTER_SPARC", "FORMAT_AUTO", "FORMAT_XZ", "FORMAT_ALONE", "FORMAT_RAW", "MF_HC3", "MF_HC4", "MF_BT2", "MF_BT3", "MF_BT4", "MODE_FAST", "MODE_NORMAL", "PRESET_DEFAULT", "PRESET_EXTREME", "LZMACompressor", "LZMADecompressor", "LZMAFile", "LZMAError", "open", "compress", "decompress", "is_check_supported", ] import builtins import io import os from _lzma import * from _lzma import _encode_filter_properties, _decode_filter_properties import _compression _MODE_CLOSED = 0 _MODE_READ = 1 # Value 2 no longer used _MODE_WRITE = 3 class LZMAFile(_compression.BaseStream): """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. """ def __init__(self, filename=None, mode="r", *, format=None, check=-1, preset=None, filters=None): """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. """ self._fp = None self._closefp = False self._mode = _MODE_CLOSED if mode in ("r", "rb"): if check != -1: raise ValueError("Cannot specify an integrity check " "when opening a file for reading") if preset is not None: raise ValueError("Cannot specify a preset compression " "level when opening a file for reading") if format is None: format = FORMAT_AUTO mode_code = _MODE_READ elif mode in ("w", "wb", "a", "ab", "x", "xb"): if format is None: format = FORMAT_XZ mode_code = _MODE_WRITE self._compressor = LZMACompressor(format=format, check=check, preset=preset, filters=filters) self._pos = 0 else: raise ValueError("Invalid mode: {!r}".format(mode)) if isinstance(filename, (str, bytes, os.PathLike)): if "b" not in mode: mode += "b" self._fp = builtins.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, LZMADecompressor, trailing_error=LZMAError, format=format, filters=filters) self._buffer = io.BufferedReader(raw) 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() self._buffer = None 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 @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, size=-1): """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) return self._buffer.peek(size) 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 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. """ self._check_can_read() return self._buffer.readline(size) def write(self, data): """Write a bytes object 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 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. 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. """ 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", *, format=None, check=-1, preset=None, filters=None, encoding=None, errors=None, newline=None): """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). """ 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") lz_mode = mode.replace("t", "") binary_file = LZMAFile(filename, lz_mode, format=format, check=check, preset=preset, filters=filters) if "t" in mode: encoding = io.text_encoding(encoding) return io.TextIOWrapper(binary_file, encoding, errors, newline) else: return binary_file def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None): """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. """ comp = LZMACompressor(format, check, preset, filters) return comp.compress(data) + comp.flush() def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None): """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. """ results = [] while True: decomp = LZMADecompressor(format, memlimit, filters) try: res = decomp.decompress(data) except LZMAError: if results: break # Leftover data is not a valid LZMA/XZ stream; ignore it. else: raise # Error on the first iteration; bail out. results.append(res) if not decomp.eof: raise LZMAError("Compressed data ended before the " "end-of-stream marker was reached") data = decomp.unused_data if not data: break return b"".join(results)