golden hour
/opt/alt/python311/lib64/python3.11
⬆️ Go Up
Upload
File/Folder
Size
Actions
LICENSE.txt
13.61 KB
Del
OK
__future__.py
5.1 KB
Del
OK
__hello__.py
227 B
Del
OK
__pycache__
-
Del
OK
_aix_support.py
3.31 KB
Del
OK
_bootsubprocess.py
2.61 KB
Del
OK
_collections_abc.py
29.49 KB
Del
OK
_compat_pickle.py
8.56 KB
Del
OK
_compression.py
5.55 KB
Del
OK
_markupbase.py
14.31 KB
Del
OK
_osx_support.py
21.51 KB
Del
OK
_py_abc.py
6.04 KB
Del
OK
_pydecimal.py
223.83 KB
Del
OK
_pyio.py
91.99 KB
Del
OK
_sitebuiltins.py
3.05 KB
Del
OK
_strptime.py
24.58 KB
Del
OK
_sysconfigdata__linux_x86_64-linux-gnu.py
57.93 KB
Del
OK
_sysconfigdata_d_linux_x86_64-linux-gnu.py
57.16 KB
Del
OK
_threading_local.py
7.05 KB
Del
OK
_weakrefset.py
5.75 KB
Del
OK
abc.py
6.38 KB
Del
OK
aifc.py
33.41 KB
Del
OK
antigravity.py
500 B
Del
OK
argparse.py
97.93 KB
Del
OK
ast.py
60 KB
Del
OK
asynchat.py
11.3 KB
Del
OK
asyncio
-
Del
OK
asyncore.py
19.83 KB
Del
OK
base64.py
20.55 KB
Del
OK
bdb.py
31.7 KB
Del
OK
bisect.py
3.06 KB
Del
OK
bz2.py
11.57 KB
Del
OK
cProfile.py
6.21 KB
Del
OK
calendar.py
24.15 KB
Del
OK
cgi.py
33.63 KB
Del
OK
cgitb.py
12.13 KB
Del
OK
chunk.py
5.37 KB
Del
OK
cmd.py
14.52 KB
Del
OK
code.py
10.37 KB
Del
OK
codecs.py
36.28 KB
Del
OK
codeop.py
5.77 KB
Del
OK
collections
-
Del
OK
colorsys.py
3.97 KB
Del
OK
compileall.py
19.78 KB
Del
OK
concurrent
-
Del
OK
config-3.11-x86_64-linux-gnu
-
Del
OK
configparser.py
54.36 KB
Del
OK
contextlib.py
26.77 KB
Del
OK
contextvars.py
129 B
Del
OK
copy.py
8.48 KB
Del
OK
copyreg.py
7.5 KB
Del
OK
crypt.py
3.82 KB
Del
OK
csv.py
15.65 KB
Del
OK
ctypes
-
Del
OK
curses
-
Del
OK
dataclasses.py
57.1 KB
Del
OK
datetime.py
89.68 KB
Del
OK
dbm
-
Del
OK
decimal.py
320 B
Del
OK
difflib.py
81.36 KB
Del
OK
dis.py
28.23 KB
Del
OK
distutils
-
Del
OK
doctest.py
103.81 KB
Del
OK
email
-
Del
OK
encodings
-
Del
OK
ensurepip
-
Del
OK
enum.py
77.72 KB
Del
OK
filecmp.py
9.94 KB
Del
OK
fileinput.py
15.35 KB
Del
OK
fnmatch.py
5.86 KB
Del
OK
fractions.py
28 KB
Del
OK
ftplib.py
34.98 KB
Del
OK
functools.py
37.51 KB
Del
OK
genericpath.py
5.12 KB
Del
OK
getopt.py
7.31 KB
Del
OK
getpass.py
5.85 KB
Del
OK
gettext.py
20.82 KB
Del
OK
glob.py
8.53 KB
Del
OK
graphlib.py
9.43 KB
Del
OK
gzip.py
23.51 KB
Del
OK
hashlib.py
11.49 KB
Del
OK
heapq.py
22.48 KB
Del
OK
hmac.py
7.54 KB
Del
OK
html
-
Del
OK
http
-
Del
OK
imaplib.py
53.92 KB
Del
OK
imghdr.py
3.86 KB
Del
OK
imp.py
10.36 KB
Del
OK
importlib
-
Del
OK
inspect.py
120.53 KB
Del
OK
io.py
4.22 KB
Del
OK
ipaddress.py
79.51 KB
Del
OK
json
-
Del
OK
keyword.py
1.04 KB
Del
OK
lib-dynload
-
Del
OK
lib2to3
-
Del
OK
linecache.py
5.52 KB
Del
OK
locale.py
77.24 KB
Del
OK
logging
-
Del
OK
lzma.py
12.97 KB
Del
OK
mailbox.py
76.98 KB
Del
OK
mailcap.py
9.15 KB
Del
OK
mimetypes.py
22.42 KB
Del
OK
modulefinder.py
23.14 KB
Del
OK
multiprocessing
-
Del
OK
netrc.py
6.77 KB
Del
OK
nntplib.py
40.12 KB
Del
OK
ntpath.py
28.09 KB
Del
OK
nturl2path.py
2.82 KB
Del
OK
numbers.py
10.11 KB
Del
OK
opcode.py
10.2 KB
Del
OK
operator.py
10.71 KB
Del
OK
optparse.py
58.95 KB
Del
OK
os.py
38.6 KB
Del
OK
pathlib.py
47.43 KB
Del
OK
pdb.py
62.68 KB
Del
OK
pickle.py
63.61 KB
Del
OK
pickletools.py
91.66 KB
Del
OK
pipes.py
8.77 KB
Del
OK
pkgutil.py
24.06 KB
Del
OK
platform.py
41.3 KB
Del
OK
plistlib.py
27.92 KB
Del
OK
poplib.py
14.84 KB
Del
OK
posixpath.py
16.67 KB
Del
OK
pprint.py
24.01 KB
Del
OK
profile.py
22.36 KB
Del
OK
pstats.py
28.67 KB
Del
OK
pty.py
6.17 KB
Del
OK
py_compile.py
7.65 KB
Del
OK
pyclbr.py
11.13 KB
Del
OK
pydoc.py
110.02 KB
Del
OK
pydoc_data
-
Del
OK
queue.py
11.23 KB
Del
OK
quopri.py
7.11 KB
Del
OK
random.py
31.41 KB
Del
OK
re
-
Del
OK
reprlib.py
5.31 KB
Del
OK
rlcompleter.py
7.64 KB
Del
OK
runpy.py
12.85 KB
Del
OK
sched.py
6.2 KB
Del
OK
secrets.py
1.98 KB
Del
OK
selectors.py
19.21 KB
Del
OK
shelve.py
8.36 KB
Del
OK
shlex.py
13.18 KB
Del
OK
shutil.py
55.19 KB
Del
OK
signal.py
2.44 KB
Del
OK
site-packages
-
Del
OK
site.py
22.45 KB
Del
OK
smtpd.py
30.44 KB
Del
OK
smtplib.py
44.37 KB
Del
OK
sndhdr.py
7.27 KB
Del
OK
socket.py
36.68 KB
Del
OK
socketserver.py
26.94 KB
Del
OK
sqlite3
-
Del
OK
sre_compile.py
231 B
Del
OK
sre_constants.py
232 B
Del
OK
sre_parse.py
229 B
Del
OK
ssl.py
53.03 KB
Del
OK
stat.py
5.36 KB
Del
OK
statistics.py
46.59 KB
Del
OK
string.py
11.51 KB
Del
OK
stringprep.py
12.61 KB
Del
OK
struct.py
257 B
Del
OK
subprocess.py
86.65 KB
Del
OK
sunau.py
18.05 KB
Del
OK
symtable.py
10.13 KB
Del
OK
sysconfig.py
29.6 KB
Del
OK
tabnanny.py
11.05 KB
Del
OK
tarfile.py
109.33 KB
Del
OK
telnetlib.py
22.75 KB
Del
OK
tempfile.py
31.13 KB
Del
OK
textwrap.py
19.26 KB
Del
OK
this.py
1003 B
Del
OK
threading.py
56.87 KB
Del
OK
timeit.py
13.21 KB
Del
OK
token.py
2.33 KB
Del
OK
tokenize.py
25.72 KB
Del
OK
tomllib
-
Del
OK
trace.py
28.51 KB
Del
OK
traceback.py
39.6 KB
Del
OK
tracemalloc.py
17.62 KB
Del
OK
tty.py
879 B
Del
OK
types.py
9.83 KB
Del
OK
typing.py
118.12 KB
Del
OK
unittest
-
Del
OK
urllib
-
Del
OK
uu.py
7.17 KB
Del
OK
uuid.py
26.95 KB
Del
OK
venv
-
Del
OK
warnings.py
20.62 KB
Del
OK
wave.py
21.31 KB
Del
OK
weakref.py
21.01 KB
Del
OK
webbrowser.py
24.56 KB
Del
OK
wsgiref
-
Del
OK
xdrlib.py
5.84 KB
Del
OK
xml
-
Del
OK
xmlrpc
-
Del
OK
zipapp.py
7.36 KB
Del
OK
zipfile.py
92.23 KB
Del
OK
zipimport.py
30.17 KB
Del
OK
zoneinfo
-
Del
OK
Edit: code.py
"""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