/
opt
/
alt
/
python34
/
lib64
/
python3.4
/
/opt/alt/python34/lib64/python3.4
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.4m/
-
0755
rm
ctypes/
-
0755
rm
curses/
-
0755
rm
dbm/
-
0755
rm
distutils/
-
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
lib2to3/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
plat-linux/
-
0755
rm
pydoc_data/
-
0755
rm
site-packages/
-
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
__pycache__/
-
0755
rm
abc.py
8624
0644
edit
dl
rm
aifc.py
31578
0644
edit
dl
rm
antigravity.py
475
0644
edit
dl
rm
argparse.py
90027
0644
edit
dl
rm
ast.py
12034
0644
edit
dl
rm
asynchat.py
11825
0644
edit
dl
rm
asyncore.py
20998
0644
edit
dl
rm
base64.py
20180
0755
edit
dl
rm
bdb.py
23354
0644
edit
dl
rm
binhex.py
13928
0644
edit
dl
rm
bisect.py
2595
0644
edit
dl
rm
bz2.py
18860
0644
edit
dl
rm
calendar.py
22941
0644
edit
dl
rm
cgi.py
35941
0755
edit
dl
rm
cgitb.py
12041
0644
edit
dl
rm
chunk.py
5425
0644
edit
dl
rm
cmd.py
14860
0644
edit
dl
rm
code.py
10037
0644
edit
dl
rm
codecs.py
35910
0644
edit
dl
rm
codeop.py
5994
0644
edit
dl
rm
colorsys.py
4064
0644
edit
dl
rm
compileall.py
9618
0644
edit
dl
rm
configparser.py
49698
0644
edit
dl
rm
contextlib.py
11639
0644
edit
dl
rm
copy.py
9005
0644
edit
dl
rm
copyreg.py
6833
0644
edit
dl
rm
cProfile.py
5324
0755
edit
dl
rm
crypt.py
1879
0644
edit
dl
rm
csv.py
16185
0644
edit
dl
rm
datetime.py
75804
0644
edit
dl
rm
decimal.py
228688
0644
edit
dl
rm
difflib.py
81684
0644
edit
dl
rm
dis.py
17160
0644
edit
dl
rm
doctest.py
104492
0644
edit
dl
rm
dummy_threading.py
2815
0644
edit
dl
rm
enum.py
21538
0644
edit
dl
rm
filecmp.py
9830
0644
edit
dl
rm
fileinput.py
14865
0644
edit
dl
rm
fnmatch.py
3163
0644
edit
dl
rm
formatter.py
15173
0644
edit
dl
rm
fractions.py
23203
0644
edit
dl
rm
ftplib.py
38532
0644
edit
dl
rm
functools.py
28511
0644
edit
dl
rm
genericpath.py
3882
0644
edit
dl
rm
getopt.py
7489
0644
edit
dl
rm
getpass.py
6069
0644
edit
dl
rm
gettext.py
20767
0644
edit
dl
rm
glob.py
3461
0644
edit
dl
rm
gzip.py
24314
0644
edit
dl
rm
hashlib.py
9850
0644
edit
dl
rm
heapq.py
17997
0644
edit
dl
rm
hmac.py
5063
0644
edit
dl
rm
imaplib.py
50267
0644
edit
dl
rm
imghdr.py
3528
0644
edit
dl
rm
imp.py
9984
0644
edit
dl
rm
inspect.py
104640
0644
edit
dl
rm
io.py
3396
0644
edit
dl
rm
ipaddress.py
71598
0644
edit
dl
rm
keyword.py
2222
0755
edit
dl
rm
linecache.py
3953
0644
edit
dl
rm
locale.py
74530
0644
edit
dl
rm
lzma.py
19371
0644
edit
dl
rm
macpath.py
5619
0644
edit
dl
rm
macurl2path.py
2732
0644
edit
dl
rm
mailbox.py
78382
0644
edit
dl
rm
mailcap.py
7437
0644
edit
dl
rm
mimetypes.py
20781
0644
edit
dl
rm
modulefinder.py
23421
0644
edit
dl
rm
netrc.py
5748
0644
edit
dl
rm
nntplib.py
43082
0644
edit
dl
rm
ntpath.py
20477
0644
edit
dl
rm
nturl2path.py
2444
0644
edit
dl
rm
numbers.py
10243
0644
edit
dl
rm
opcode.py
5442
0644
edit
dl
rm
operator.py
9195
0644
edit
dl
rm
optparse.py
60346
0644
edit
dl
rm
os.py
33882
0644
edit
dl
rm
pathlib.py
42467
0644
edit
dl
rm
pdb.py
60992
0755
edit
dl
rm
pickle.py
55989
0644
edit
dl
rm
pickletools.py
91762
0644
edit
dl
rm
pipes.py
8916
0644
edit
dl
rm
pkgutil.py
21215
0644
edit
dl
rm
platform.py
46761
0755
edit
dl
rm
plistlib.py
31791
0644
edit
dl
rm
poplib.py
14319
0644
edit
dl
rm
posixpath.py
13448
0644
edit
dl
rm
pprint.py
14919
0644
edit
dl
rm
profile.py
22032
0755
edit
dl
rm
pstats.py
26316
0644
edit
dl
rm
pty.py
4763
0644
edit
dl
rm
pyclbr.py
13520
0644
edit
dl
rm
pydoc.py
103011
0755
edit
dl
rm
py_compile.py
7103
0644
edit
dl
rm
queue.py
8835
0644
edit
dl
rm
quopri.py
7265
0755
edit
dl
rm
random.py
26084
0644
edit
dl
rm
re.py
15604
0644
edit
dl
rm
reprlib.py
5110
0644
edit
dl
rm
rlcompleter.py
6069
0644
edit
dl
rm
runpy.py
10816
0644
edit
dl
rm
sched.py
6354
0644
edit
dl
rm
selectors.py
17097
0644
edit
dl
rm
shelve.py
8528
0644
edit
dl
rm
shlex.py
11548
0644
edit
dl
rm
shutil.py
39902
0644
edit
dl
rm
site.py
21553
0644
edit
dl
rm
smtpd.py
29991
0755
edit
dl
rm
smtplib.py
38971
0755
edit
dl
rm
sndhdr.py
6256
0644
edit
dl
rm
socket.py
19067
0644
edit
dl
rm
socketserver.py
24372
0644
edit
dl
rm
sre_compile.py
19903
0644
edit
dl
rm
sre_constants.py
7267
0644
edit
dl
rm
sre_parse.py
31429
0644
edit
dl
rm
ssl.py
34747
0644
edit
dl
rm
stat.py
4400
0644
edit
dl
rm
statistics.py
19556
0644
edit
dl
rm
string.py
11445
0644
edit
dl
rm
stringprep.py
12917
0644
edit
dl
rm
struct.py
257
0644
edit
dl
rm
subprocess.py
64549
0644
edit
dl
rm
sunau.py
18095
0644
edit
dl
rm
symbol.py
2053
0755
edit
dl
rm
symtable.py
7404
0644
edit
dl
rm
sysconfig.py
24632
0644
edit
dl
rm
tabnanny.py
11410
0755
edit
dl
rm
tarfile.py
91557
0755
edit
dl
rm
telnetlib.py
23074
0644
edit
dl
rm
tempfile.py
22525
0644
edit
dl
rm
textwrap.py
19282
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
48802
0644
edit
dl
rm
timeit.py
11972
0755
edit
dl
rm
token.py
3034
0644
edit
dl
rm
tokenize.py
25596
0644
edit
dl
rm
trace.py
31487
0755
edit
dl
rm
traceback.py
11167
0644
edit
dl
rm
tracemalloc.py
15651
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
types.py
5411
0644
edit
dl
rm
uu.py
6766
0755
edit
dl
rm
uuid.py
23724
0644
edit
dl
rm
warnings.py
14303
0644
edit
dl
rm
wave.py
17682
0644
edit
dl
rm
weakref.py
19384
0644
edit
dl
rm
webbrowser.py
21432
0755
edit
dl
rm
xdrlib.py
5913
0644
edit
dl
rm
zipfile.py
68547
0644
edit
dl
rm
_bootlocale.py
1301
0644
edit
dl
rm
_collections_abc.py
19898
0644
edit
dl
rm
_compat_pickle.py
8318
0644
edit
dl
rm
_dummy_thread.py
4872
0644
edit
dl
rm
_markupbase.py
14598
0644
edit
dl
rm
_osx_support.py
19101
0644
edit
dl
rm
_pyio.py
73893
0644
edit
dl
rm
_sitebuiltins.py
3115
0644
edit
dl
rm
_strptime.py
22053
0644
edit
dl
rm
_sysconfigdata.py
24480
0644
edit
dl
rm
_threading_local.py
7410
0644
edit
dl
rm
_weakrefset.py
5705
0644
edit
dl
rm
__future__.py
4584
0644
edit
dl
rm
__phello__.foo.py
64
0644
edit
dl
rm
Edit:
/opt/alt/python34/lib64/python3.4/bz2.py
(18860B)
"""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 warnings try: from threading import RLock except ImportError: from dummy_threading import RLock from _bz2 import BZ2Compressor, BZ2Decompressor _MODE_CLOSED = 0 _MODE_READ = 1 _MODE_READ_EOF = 2 _MODE_WRITE = 3 _BUFFER_SIZE = 8192 class BZ2File(io.BufferedIOBase): """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", buffering=None, compresslevel=9): """Open a bzip2-compressed file. If filename is a str or bytes 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'. buffering is ignored. Its use is deprecated. 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. """ # This lock must be recursive, so that BufferedIOBase's # readline(), readlines() and writelines() don't deadlock. self._lock = RLock() self._fp = None self._closefp = False self._mode = _MODE_CLOSED self._pos = 0 self._size = -1 if buffering is not None: warnings.warn("Use of 'buffering' argument is deprecated", DeprecationWarning) 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 self._decompressor = BZ2Decompressor() self._buffer = b"" self._buffer_offset = 0 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)): 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 or bytes object, or a file") 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. """ with self._lock: if self._mode == _MODE_CLOSED: return try: if self._mode in (_MODE_READ, _MODE_READ_EOF): self._decompressor = 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 self._buffer = b"" self._buffer_offset = 0 @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._fp.seekable() def readable(self): """Return whether the file was opened for reading.""" self._check_not_closed() return self._mode in (_MODE_READ, _MODE_READ_EOF) def writable(self): """Return whether the file was opened for writing.""" self._check_not_closed() return self._mode == _MODE_WRITE # Mode-checking helper functions. def _check_not_closed(self): if self.closed: raise ValueError("I/O operation on closed file") def _check_can_read(self): if self._mode not in (_MODE_READ, _MODE_READ_EOF): self._check_not_closed() raise io.UnsupportedOperation("File not open for reading") def _check_can_write(self): if self._mode != _MODE_WRITE: self._check_not_closed() raise io.UnsupportedOperation("File not open for writing") def _check_can_seek(self): if self._mode not in (_MODE_READ, _MODE_READ_EOF): self._check_not_closed() raise io.UnsupportedOperation("Seeking is only supported " "on files open for reading") if not self._fp.seekable(): raise io.UnsupportedOperation("The underlying file object " "does not support seeking") # Fill the readahead buffer if it is empty. Returns False on EOF. def _fill_buffer(self): if self._mode == _MODE_READ_EOF: return False # Depending on the input data, our call to the decompressor may not # return any data. In this case, try again after reading another block. while self._buffer_offset == len(self._buffer): rawblock = (self._decompressor.unused_data or self._fp.read(_BUFFER_SIZE)) if not rawblock: if self._decompressor.eof: # End-of-stream marker and end of file. We're good. self._mode = _MODE_READ_EOF self._size = self._pos return False else: # Problem - we were expecting more compressed data. raise EOFError("Compressed file ended before the " "end-of-stream marker was reached") if self._decompressor.eof: # Continue to next stream. self._decompressor = BZ2Decompressor() try: self._buffer = self._decompressor.decompress(rawblock) except OSError: # Trailing data isn't a valid bzip2 stream. We're done here. self._mode = _MODE_READ_EOF self._size = self._pos return False else: self._buffer = self._decompressor.decompress(rawblock) self._buffer_offset = 0 return True # Read data until EOF. # If return_data is false, consume the data without returning it. def _read_all(self, return_data=True): # The loop assumes that _buffer_offset is 0. Ensure that this is true. self._buffer = self._buffer[self._buffer_offset:] self._buffer_offset = 0 blocks = [] while self._fill_buffer(): if return_data: blocks.append(self._buffer) self._pos += len(self._buffer) self._buffer = b"" if return_data: return b"".join(blocks) # Read a block of up to n bytes. # If return_data is false, consume the data without returning it. def _read_block(self, n, return_data=True): # If we have enough data buffered, return immediately. end = self._buffer_offset + n if end <= len(self._buffer): data = self._buffer[self._buffer_offset : end] self._buffer_offset = end self._pos += len(data) return data if return_data else None # The loop assumes that _buffer_offset is 0. Ensure that this is true. self._buffer = self._buffer[self._buffer_offset:] self._buffer_offset = 0 blocks = [] while n > 0 and self._fill_buffer(): if n < len(self._buffer): data = self._buffer[:n] self._buffer_offset = n else: data = self._buffer self._buffer = b"" if return_data: blocks.append(data) self._pos += len(data) n -= len(data) if return_data: return b"".join(blocks) 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. """ with self._lock: self._check_can_read() if not self._fill_buffer(): return b"" return self._buffer[self._buffer_offset:] 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. """ with self._lock: self._check_can_read() if size == 0: return b"" elif size < 0: return self._read_all() else: return self._read_block(size) def read1(self, size=-1): """Read up to size uncompressed bytes, while trying to avoid making multiple reads from the underlying stream. Returns b'' if the file is at EOF. """ # Usually, read1() calls _fp.read() at most once. However, sometimes # this does not give enough data for the decompressor to make progress. # In this case we make multiple reads, to avoid returning b"". with self._lock: self._check_can_read() if (size == 0 or # Only call _fill_buffer() if the buffer is actually empty. # This gives a significant speedup if *size* is small. (self._buffer_offset == len(self._buffer) and not self._fill_buffer())): return b"" if size > 0: data = self._buffer[self._buffer_offset : self._buffer_offset + size] self._buffer_offset += len(data) else: data = self._buffer[self._buffer_offset:] self._buffer = b"" self._buffer_offset = 0 self._pos += len(data) return data def readinto(self, b): """Read up to len(b) bytes into b. Returns the number of bytes read (0 for EOF). """ with self._lock: return io.BufferedIOBase.readinto(self, 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__() with self._lock: self._check_can_read() # Shortcut for the common case - the whole line is in the buffer. if size < 0: end = self._buffer.find(b"\n", self._buffer_offset) + 1 if end > 0: line = self._buffer[self._buffer_offset : end] self._buffer_offset = end self._pos += len(line) return line return io.BufferedIOBase.readline(self, 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__() with self._lock: return io.BufferedIOBase.readlines(self, size) def write(self, data): """Write a byte string to the file. Returns the number of uncompressed bytes written, which is always len(data). Note that due to buffering, the file on disk may not reflect the data written until close() is called. """ with self._lock: self._check_can_write() compressed = self._compressor.compress(data) self._fp.write(compressed) self._pos += len(data) return len(data) 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. """ with self._lock: return io.BufferedIOBase.writelines(self, seq) # Rewind the file to the beginning of the data stream. def _rewind(self): self._fp.seek(0, 0) self._mode = _MODE_READ self._pos = 0 self._decompressor = BZ2Decompressor() self._buffer = b"" self._buffer_offset = 0 def seek(self, offset, whence=0): """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. """ with self._lock: self._check_can_seek() # Recalculate offset as an absolute file position. if whence == 0: pass elif whence == 1: offset = self._pos + offset elif whence == 2: # Seeking relative to EOF - we need to know the file's size. if self._size < 0: self._read_all(return_data=False) offset = self._size + offset else: raise ValueError("Invalid value for whence: %s" % (whence,)) # Make it so that offset is the number of bytes to skip forward. if offset < self._pos: self._rewind() else: offset -= self._pos # Read and discard data until we reach the desired position. self._read_block(offset, return_data=False) return self._pos def tell(self): """Return the current file position.""" with self._lock: self._check_not_closed() 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 or bytes 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: 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