/
opt
/
alt
/
python311
/
lib64
/
python3.11
/
/opt/alt/python311/lib64/python3.11
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.11-x86_64-linux-gnu/
-
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
importlib/
-
0755
rm
json/
-
0755
rm
lib-dynload/
-
0755
rm
lib2to3/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
pydoc_data/
-
0755
rm
re/
-
0755
rm
site-packages/
-
0755
rm
sqlite3/
-
0755
rm
tomllib/
-
0755
rm
unittest/
-
0755
rm
urllib/
-
0755
rm
venv/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
xmlrpc/
-
0755
rm
zoneinfo/
-
0755
rm
__phello__/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
6538
0644
edit
dl
rm
aifc.py
34211
0644
edit
dl
rm
antigravity.py
500
0644
edit
dl
rm
argparse.py
100283
0644
edit
dl
rm
ast.py
61444
0644
edit
dl
rm
asynchat.py
11570
0644
edit
dl
rm
asyncore.py
20310
0644
edit
dl
rm
base64.py
21041
0755
edit
dl
rm
bdb.py
32463
0644
edit
dl
rm
bisect.py
3135
0644
edit
dl
rm
bz2.py
11847
0644
edit
dl
rm
calendar.py
24731
0644
edit
dl
rm
cgi.py
34432
0755
edit
dl
rm
cgitb.py
12421
0644
edit
dl
rm
chunk.py
5500
0644
edit
dl
rm
cmd.py
14873
0644
edit
dl
rm
code.py
10622
0644
edit
dl
rm
codecs.py
37150
0644
edit
dl
rm
codeop.py
5907
0644
edit
dl
rm
colorsys.py
4062
0644
edit
dl
rm
compileall.py
20252
0644
edit
dl
rm
configparser.py
55660
0644
edit
dl
rm
contextlib.py
27414
0644
edit
dl
rm
contextvars.py
129
0644
edit
dl
rm
copy.py
8681
0644
edit
dl
rm
copyreg.py
7677
0644
edit
dl
rm
cProfile.py
6359
0755
edit
dl
rm
crypt.py
3913
0644
edit
dl
rm
csv.py
16030
0644
edit
dl
rm
dataclasses.py
58472
0644
edit
dl
rm
datetime.py
91832
0644
edit
dl
rm
decimal.py
320
0644
edit
dl
rm
difflib.py
83308
0644
edit
dl
rm
dis.py
28906
0644
edit
dl
rm
doctest.py
106297
0644
edit
dl
rm
enum.py
79583
0644
edit
dl
rm
filecmp.py
10178
0644
edit
dl
rm
fileinput.py
15714
0644
edit
dl
rm
fnmatch.py
5999
0644
edit
dl
rm
fractions.py
28677
0644
edit
dl
rm
ftplib.py
35815
0644
edit
dl
rm
functools.py
38413
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
21320
0644
edit
dl
rm
glob.py
8732
0644
edit
dl
rm
graphlib.py
9656
0644
edit
dl
rm
gzip.py
24074
0644
edit
dl
rm
hashlib.py
11765
0644
edit
dl
rm
heapq.py
23024
0644
edit
dl
rm
hmac.py
7716
0644
edit
dl
rm
imaplib.py
55217
0644
edit
dl
rm
imghdr.py
3952
0644
edit
dl
rm
imp.py
10606
0644
edit
dl
rm
inspect.py
123419
0644
edit
dl
rm
io.py
4320
0644
edit
dl
rm
ipaddress.py
79124
0644
edit
dl
rm
keyword.py
1061
0644
edit
dl
rm
LICENSE.txt
13936
0644
edit
dl
rm
linecache.py
5649
0644
edit
dl
rm
locale.py
79095
0644
edit
dl
rm
lzma.py
13277
0644
edit
dl
rm
mailbox.py
78830
0644
edit
dl
rm
mailcap.py
9369
0644
edit
dl
rm
mimetypes.py
22962
0644
edit
dl
rm
modulefinder.py
23699
0644
edit
dl
rm
netrc.py
6929
0644
edit
dl
rm
nntplib.py
41087
0644
edit
dl
rm
ntpath.py
30222
0644
edit
dl
rm
nturl2path.py
2887
0644
edit
dl
rm
numbers.py
10348
0644
edit
dl
rm
opcode.py
10447
0644
edit
dl
rm
operator.py
10965
0644
edit
dl
rm
optparse.py
60369
0644
edit
dl
rm
os.py
39530
0644
edit
dl
rm
pathlib.py
48566
0644
edit
dl
rm
pdb.py
64186
0755
edit
dl
rm
pickle.py
65132
0644
edit
dl
rm
pickletools.py
93861
0644
edit
dl
rm
pipes.py
8978
0644
edit
dl
rm
pkgutil.py
24638
0644
edit
dl
rm
platform.py
42287
0755
edit
dl
rm
plistlib.py
28354
0644
edit
dl
rm
poplib.py
15198
0644
edit
dl
rm
posixpath.py
17013
0644
edit
dl
rm
pprint.py
24583
0644
edit
dl
rm
profile.py
22896
0755
edit
dl
rm
pstats.py
29356
0644
edit
dl
rm
pty.py
6317
0644
edit
dl
rm
pyclbr.py
11396
0644
edit
dl
rm
pydoc.py
112664
0755
edit
dl
rm
py_compile.py
7837
0644
edit
dl
rm
queue.py
11496
0644
edit
dl
rm
quopri.py
7281
0755
edit
dl
rm
random.py
32162
0644
edit
dl
rm
reprlib.py
5437
0644
edit
dl
rm
rlcompleter.py
7827
0644
edit
dl
rm
runpy.py
13159
0644
edit
dl
rm
sched.py
6351
0644
edit
dl
rm
secrets.py
2028
0644
edit
dl
rm
selectors.py
19671
0644
edit
dl
rm
shelve.py
8560
0644
edit
dl
rm
shlex.py
13501
0644
edit
dl
rm
shutil.py
56517
0644
edit
dl
rm
signal.py
2495
0644
edit
dl
rm
site.py
22987
0644
edit
dl
rm
smtpd.py
31175
0755
edit
dl
rm
smtplib.py
45431
0755
edit
dl
rm
sndhdr.py
7448
0644
edit
dl
rm
socket.py
37557
0644
edit
dl
rm
socketserver.py
27586
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
54305
0644
edit
dl
rm
stat.py
5485
0644
edit
dl
rm
statistics.py
47705
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
88725
0644
edit
dl
rm
sunau.py
18480
0644
edit
dl
rm
symtable.py
10368
0644
edit
dl
rm
sysconfig.py
30315
0644
edit
dl
rm
tabnanny.py
11312
0755
edit
dl
rm
tarfile.py
107876
0755
edit
dl
rm
telnetlib.py
23301
0644
edit
dl
rm
tempfile.py
31873
0644
edit
dl
rm
textwrap.py
19718
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
58231
0644
edit
dl
rm
timeit.py
13532
0755
edit
dl
rm
token.py
2386
0644
edit
dl
rm
tokenize.py
26336
0644
edit
dl
rm
trace.py
29196
0755
edit
dl
rm
traceback.py
40547
0644
edit
dl
rm
tracemalloc.py
18047
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
types.py
10067
0644
edit
dl
rm
typing.py
120951
0644
edit
dl
rm
uu.py
7341
0644
edit
dl
rm
uuid.py
27597
0644
edit
dl
rm
warnings.py
21110
0644
edit
dl
rm
wave.py
21818
0644
edit
dl
rm
weakref.py
21513
0644
edit
dl
rm
webbrowser.py
25149
0755
edit
dl
rm
xdrlib.py
5977
0644
edit
dl
rm
zipapp.py
7535
0644
edit
dl
rm
zipfile.py
93788
0644
edit
dl
rm
zipimport.py
30897
0644
edit
dl
rm
_aix_support.py
3389
0644
edit
dl
rm
_bootsubprocess.py
2675
0644
edit
dl
rm
_collections_abc.py
30193
0644
edit
dl
rm
_compat_pickle.py
8761
0644
edit
dl
rm
_compression.py
5681
0644
edit
dl
rm
_markupbase.py
14653
0644
edit
dl
rm
_osx_support.py
22023
0644
edit
dl
rm
_pydecimal.py
229202
0644
edit
dl
rm
_pyio.py
94193
0644
edit
dl
rm
_py_abc.py
6189
0644
edit
dl
rm
_sitebuiltins.py
3128
0644
edit
dl
rm
_strptime.py
25175
0644
edit
dl
rm
_sysconfigdata_d_linux_x86_64-linux-gnu.py
58878
0644
edit
dl
rm
_sysconfigdata__linux_x86_64-linux-gnu.py
59645
0644
edit
dl
rm
_threading_local.py
7220
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/alt/python311/lib64/python3.11/code.py
(10622B)
"""Utilities needed to emulate Python's interactive interpreter. """ # Inspired by similar code by Jeff Epler and Fredrik Lundh. import sys import traceback from codeop import CommandCompiler, compile_command __all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact", "compile_command"] class InteractiveInterpreter: """Base class for InteractiveConsole. This class deals with parsing and interpreter state (the user's namespace); it doesn't deal with input buffering or prompting or input file naming (the filename is always passed in explicitly). """ def __init__(self, locals=None): """Constructor. The optional 'locals' argument specifies the dictionary in which code will be executed; it defaults to a newly created dictionary with key "__name__" set to "__console__" and key "__doc__" set to None. """ if locals is None: locals = {"__name__": "__console__", "__doc__": None} self.locals = locals self.compile = CommandCompiler() def runsource(self, source, filename="<input>", symbol="single"): """Compile and run some source in the interpreter. Arguments are as for compile_command(). One of several things can happen: 1) The input is incorrect; compile_command() raised an exception (SyntaxError or OverflowError). A syntax traceback will be printed by calling the showsyntaxerror() method. 2) The input is incomplete, and more input is required; compile_command() returned None. Nothing happens. 3) The input is complete; compile_command() returned a code object. The code is executed by calling self.runcode() (which also handles run-time exceptions, except for SystemExit). The return value is True in case 2, False in the other cases (unless an exception is raised). The return value can be used to decide whether to use sys.ps1 or sys.ps2 to prompt the next line. """ try: code = self.compile(source, filename, symbol) except (OverflowError, SyntaxError, ValueError): # Case 1 self.showsyntaxerror(filename) return False if code is None: # Case 2 return True # Case 3 self.runcode(code) return False def runcode(self, code): """Execute a code object. When an exception occurs, self.showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is reraised. A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may not always be caught. The caller should be prepared to deal with it. """ try: exec(code, self.locals) except SystemExit: raise except: self.showtraceback() def showsyntaxerror(self, filename=None): """Display the syntax error that just occurred. This doesn't display a stack trace because there isn't one. If a filename is given, it is stuffed in the exception instead of what was there before (because Python's parser always uses "<string>" when reading from a string). The output is written by self.write(), below. """ type, value, tb = sys.exc_info() sys.last_type = type sys.last_value = value sys.last_traceback = tb if filename and type is SyntaxError: # Work hard to stuff the correct filename in the exception try: msg, (dummy_filename, lineno, offset, line) = value.args except ValueError: # Not the format we expect; leave it alone pass else: # Stuff in the right filename value = SyntaxError(msg, (filename, lineno, offset, line)) sys.last_value = value if sys.excepthook is sys.__excepthook__: lines = traceback.format_exception_only(type, value) self.write(''.join(lines)) else: # If someone has set sys.excepthook, we let that take precedence # over self.write sys.excepthook(type, value, tb) def showtraceback(self): """Display the exception that just occurred. We remove the first stack item because it is our own code. The output is written by self.write(), below. """ sys.last_type, sys.last_value, last_tb = ei = sys.exc_info() sys.last_traceback = last_tb try: lines = traceback.format_exception(ei[0], ei[1], last_tb.tb_next) if sys.excepthook is sys.__excepthook__: self.write(''.join(lines)) else: # If someone has set sys.excepthook, we let that take precedence # over self.write sys.excepthook(ei[0], ei[1], last_tb) finally: last_tb = ei = None def write(self, data): """Write a string. The base implementation writes to sys.stderr; a subclass may replace this with a different implementation. """ sys.stderr.write(data) class InteractiveConsole(InteractiveInterpreter): """Closely emulate the behavior of the interactive Python interpreter. This class builds on InteractiveInterpreter and adds prompting using the familiar sys.ps1 and sys.ps2, and input buffering. """ def __init__(self, locals=None, filename="<console>"): """Constructor. The optional locals argument will be passed to the InteractiveInterpreter base class. The optional filename argument should specify the (file)name of the input stream; it will show up in tracebacks. """ InteractiveInterpreter.__init__(self, locals) self.filename = filename self.resetbuffer() def resetbuffer(self): """Reset the input buffer.""" self.buffer = [] def interact(self, banner=None, exitmsg=None): """Closely emulate the interactive Python console. The optional banner argument specifies the banner to print before the first interaction; by default it prints a banner similar to the one printed by the real Python interpreter, followed by the current class name in parentheses (so as not to confuse this with the real interpreter -- since it's so close!). The optional exitmsg argument specifies the exit message printed when exiting. Pass the empty string to suppress printing an exit message. If exitmsg is not given or None, a default message is printed. """ try: sys.ps1 except AttributeError: sys.ps1 = ">>> " try: sys.ps2 except AttributeError: sys.ps2 = "... " cprt = 'Type "help", "copyright", "credits" or "license" for more information.' if banner is None: self.write("Python %s on %s\n%s\n(%s)\n" % (sys.version, sys.platform, cprt, self.__class__.__name__)) elif banner: self.write("%s\n" % str(banner)) more = 0 while 1: try: if more: prompt = sys.ps2 else: prompt = sys.ps1 try: line = self.raw_input(prompt) except EOFError: self.write("\n") break else: more = self.push(line) except KeyboardInterrupt: self.write("\nKeyboardInterrupt\n") self.resetbuffer() more = 0 if exitmsg is None: self.write('now exiting %s...\n' % self.__class__.__name__) elif exitmsg != '': self.write('%s\n' % exitmsg) def push(self, line): """Push a line to the interpreter. The line should not have a trailing newline; it may have internal newlines. The line is appended to a buffer and the interpreter's runsource() method is called with the concatenated contents of the buffer as source. If this indicates that the command was executed or invalid, the buffer is reset; otherwise, the command is incomplete, and the buffer is left as it was after the line was appended. The return value is 1 if more input is required, 0 if the line was dealt with in some way (this is the same as runsource()). """ self.buffer.append(line) source = "\n".join(self.buffer) more = self.runsource(source, self.filename) if not more: self.resetbuffer() return more def raw_input(self, prompt=""): """Write a prompt and read a line. The returned line does not include the trailing newline. When the user enters the EOF key sequence, EOFError is raised. The base implementation uses the built-in function input(); a subclass may replace this with a different implementation. """ return input(prompt) def interact(banner=None, readfunc=None, local=None, exitmsg=None): """Closely emulate the interactive Python interpreter. This is a backwards compatible interface to the InteractiveConsole class. When readfunc is not specified, it attempts to import the readline module to enable GNU readline if it is available. Arguments (all optional, all default to None): banner -- passed to InteractiveConsole.interact() readfunc -- if not None, replaces InteractiveConsole.raw_input() local -- passed to InteractiveInterpreter.__init__() exitmsg -- passed to InteractiveConsole.interact() """ console = InteractiveConsole(local) if readfunc is not None: console.raw_input = readfunc else: try: import readline except ImportError: pass console.interact(banner, exitmsg) if __name__ == "__main__": import argparse parser = argparse.ArgumentParser() parser.add_argument('-q', action='store_true', help="don't print version and copyright messages") args = parser.parse_args() if args.q or sys.flags.quiet: banner = '' else: banner = None interact(banner)
Save
cmd:
run