/
snap
/
core22
/
2437
/
usr
/
lib
/
python3.10
/
/snap/core22/2437/usr/lib/python3.10
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
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
35496
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
107453
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
24245
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:
/snap/core22/2437/usr/lib/python3.10/py_compile.py
(7878B)
"""Routine to "compile" a .py file to a .pyc file. This module has intimate knowledge of the format of .pyc files. """ import enum import importlib._bootstrap_external import importlib.machinery import importlib.util import os import os.path import sys import traceback __all__ = ["compile", "main", "PyCompileError", "PycInvalidationMode"] class PyCompileError(Exception): """Exception raised when an error occurs while attempting to compile the file. To raise this exception, use raise PyCompileError(exc_type,exc_value,file[,msg]) where exc_type: exception type to be used in error message type name can be accesses as class variable 'exc_type_name' exc_value: exception value to be used in error message can be accesses as class variable 'exc_value' file: name of file being compiled to be used in error message can be accesses as class variable 'file' msg: string message to be written as error message If no value is given, a default exception message will be given, consistent with 'standard' py_compile output. message (or default) can be accesses as class variable 'msg' """ def __init__(self, exc_type, exc_value, file, msg=''): exc_type_name = exc_type.__name__ if exc_type is SyntaxError: tbtext = ''.join(traceback.format_exception_only( exc_type, exc_value)) errmsg = tbtext.replace('File "<string>"', 'File "%s"' % file) else: errmsg = "Sorry: %s: %s" % (exc_type_name,exc_value) Exception.__init__(self,msg or errmsg,exc_type_name,exc_value,file) self.exc_type_name = exc_type_name self.exc_value = exc_value self.file = file self.msg = msg or errmsg def __str__(self): return self.msg class PycInvalidationMode(enum.Enum): TIMESTAMP = 1 CHECKED_HASH = 2 UNCHECKED_HASH = 3 def _get_default_invalidation_mode(): if os.environ.get('SOURCE_DATE_EPOCH'): return PycInvalidationMode.CHECKED_HASH else: return PycInvalidationMode.TIMESTAMP def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1, invalidation_mode=None, quiet=0): """Byte-compile one Python source file to Python bytecode. :param file: The source file name. :param cfile: The target byte compiled file name. When not given, this defaults to the PEP 3147/PEP 488 location. :param dfile: Purported file name, i.e. the file name that shows up in error messages. Defaults to the source file name. :param doraise: Flag indicating whether or not an exception should be raised when a compile error is found. If an exception occurs and this flag is set to False, a string indicating the nature of the exception will be printed, and the function will return to the caller. If an exception occurs and this flag is set to True, a PyCompileError exception will be raised. :param optimize: The optimization level for the compiler. Valid values are -1, 0, 1 and 2. A value of -1 means to use the optimization level of the current interpreter, as given by -O command line options. :param invalidation_mode: :param quiet: Return full output with False or 0, errors only with 1, and no output with 2. :return: Path to the resulting byte compiled file. Note that it isn't necessary to byte-compile Python modules for execution efficiency -- Python itself byte-compiles a module when it is loaded, and if it can, writes out the bytecode to the corresponding .pyc file. However, if a Python installation is shared between users, it is a good idea to byte-compile all modules upon installation, since other users may not be able to write in the source directories, and thus they won't be able to write the .pyc file, and then they would be byte-compiling every module each time it is loaded. This can slow down program start-up considerably. See compileall.py for a script/module that uses this module to byte-compile all installed files (or all files in selected directories). Do note that FileExistsError is raised if cfile ends up pointing at a non-regular file or symlink. Because the compilation uses a file renaming, the resulting file would be regular and thus not the same type of file as it was previously. """ if invalidation_mode is None: invalidation_mode = _get_default_invalidation_mode() if cfile is None: if optimize >= 0: optimization = optimize if optimize >= 1 else '' cfile = importlib.util.cache_from_source(file, optimization=optimization) else: cfile = importlib.util.cache_from_source(file) if os.path.islink(cfile): msg = ('{} is a symlink and will be changed into a regular file if ' 'import writes a byte-compiled file to it') raise FileExistsError(msg.format(cfile)) elif os.path.exists(cfile) and not os.path.isfile(cfile): msg = ('{} is a non-regular file and will be changed into a regular ' 'one if import writes a byte-compiled file to it') raise FileExistsError(msg.format(cfile)) loader = importlib.machinery.SourceFileLoader('<py_compile>', file) source_bytes = loader.get_data(file) try: code = loader.source_to_code(source_bytes, dfile or file, _optimize=optimize) except Exception as err: py_exc = PyCompileError(err.__class__, err, dfile or file) if quiet < 2: if doraise: raise py_exc else: sys.stderr.write(py_exc.msg + '\n') return try: dirname = os.path.dirname(cfile) if dirname: os.makedirs(dirname) except FileExistsError: pass if invalidation_mode == PycInvalidationMode.TIMESTAMP: source_stats = loader.path_stats(file) bytecode = importlib._bootstrap_external._code_to_timestamp_pyc( code, source_stats['mtime'], source_stats['size']) else: source_hash = importlib.util.source_hash(source_bytes) bytecode = importlib._bootstrap_external._code_to_hash_pyc( code, source_hash, (invalidation_mode == PycInvalidationMode.CHECKED_HASH), ) mode = importlib._bootstrap_external._calc_mode(file) importlib._bootstrap_external._write_atomic(cfile, bytecode, mode) return cfile def main(): import argparse description = 'A simple command-line interface for py_compile module.' parser = argparse.ArgumentParser(description=description) parser.add_argument( '-q', '--quiet', action='store_true', help='Suppress error output', ) parser.add_argument( 'filenames', nargs='+', help='Files to compile', ) args = parser.parse_args() if args.filenames == ['-']: filenames = [filename.rstrip('\n') for filename in sys.stdin.readlines()] else: filenames = args.filenames for filename in filenames: filename = filename.rstrip('\n') try: compile(filename, doraise=True) except PyCompileError as error: if args.quiet: parser.exit(1) else: parser.exit(1, error.msg) except OSError as error: if args.quiet: parser.exit(1) else: parser.exit(1, str(error)) if __name__ == "__main__": main()
Save
cmd:
run