rgwfuncs 0.0.87__py3-none-any.whl → 0.0.89__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rgwfuncs/interactive_shell_lib.py +18 -18
- {rgwfuncs-0.0.87.dist-info → rgwfuncs-0.0.89.dist-info}/METADATA +1 -1
- {rgwfuncs-0.0.87.dist-info → rgwfuncs-0.0.89.dist-info}/RECORD +7 -7
- {rgwfuncs-0.0.87.dist-info → rgwfuncs-0.0.89.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.87.dist-info → rgwfuncs-0.0.89.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.87.dist-info → rgwfuncs-0.0.89.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.87.dist-info → rgwfuncs-0.0.89.dist-info}/top_level.txt +0 -0
@@ -14,10 +14,10 @@ from .docs_lib import * # noqa: F401, F403, E402
|
|
14
14
|
def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
15
15
|
"""
|
16
16
|
Launch an interactive prompt for inspecting and modifying local variables,
|
17
|
-
with blue-colored output and a white prompt. An extra blank line appears before
|
18
|
-
and the welcome banner
|
17
|
+
with blue-colored output and a white prompt. An extra blank line appears before
|
18
|
+
each new prompt, and the welcome banner appears in blue. No extra exit message is printed.
|
19
19
|
|
20
|
-
local_vars: dictionary of
|
20
|
+
local_vars: dictionary of variables available in the interactive shell.
|
21
21
|
"""
|
22
22
|
|
23
23
|
# ANSI color escape codes.
|
@@ -25,7 +25,7 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
25
25
|
WHITE = "\033[37m"
|
26
26
|
RESET = "\033[0m"
|
27
27
|
|
28
|
-
#
|
28
|
+
# Set up readline history.
|
29
29
|
def setup_readline() -> None:
|
30
30
|
HISTORY_FILE = os.path.expanduser("~/.rgwfuncs_shell_history")
|
31
31
|
readline.set_history_length(1000)
|
@@ -37,18 +37,18 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
37
37
|
print(f"Warning: Could not load history file: {e}")
|
38
38
|
atexit.register(readline.write_history_file, HISTORY_FILE)
|
39
39
|
|
40
|
-
# BlueStdout: wrapper for stdout to output
|
40
|
+
# BlueStdout: a wrapper for sys.stdout to ensure output is in blue.
|
41
41
|
class BlueStdout:
|
42
42
|
def __init__(self, wrapped):
|
43
43
|
self.wrapped = wrapped
|
44
44
|
self.at_line_start = True
|
45
45
|
|
46
46
|
def write(self, s):
|
47
|
-
# If
|
47
|
+
# If the output exactly matches our prompt, leave it uncolored.
|
48
48
|
if s == sys.ps1 or s == sys.ps2:
|
49
49
|
self.wrapped.write(s)
|
50
50
|
return
|
51
|
-
# Process output line by line
|
51
|
+
# Process output line by line.
|
52
52
|
lines = s.split('\n')
|
53
53
|
for i, line in enumerate(lines):
|
54
54
|
if self.at_line_start and line:
|
@@ -73,8 +73,8 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
73
73
|
def __getattr__(self, attr):
|
74
74
|
return getattr(self.wrapped, attr)
|
75
75
|
|
76
|
-
# ColorInteractiveConsole: subclass
|
77
|
-
#
|
76
|
+
# ColorInteractiveConsole: a subclass that temporarily restores the original stdout
|
77
|
+
# while reading input and prints an extra blank line before each prompt.
|
78
78
|
class ColorInteractiveConsole(code.InteractiveConsole):
|
79
79
|
def raw_input(self, prompt=""):
|
80
80
|
saved_stdout = sys.stdout
|
@@ -91,32 +91,32 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
91
91
|
if not isinstance(local_vars, dict):
|
92
92
|
raise TypeError("local_vars must be a dictionary")
|
93
93
|
|
94
|
-
#
|
94
|
+
# Initialize readline history.
|
95
95
|
setup_readline()
|
96
96
|
|
97
97
|
# Merge globals into local_vars.
|
98
98
|
local_vars.update(globals())
|
99
99
|
|
100
|
-
# Wrap ANSI escape codes with markers so
|
100
|
+
# Wrap ANSI escape codes with markers (\001 and \002) so readline ignores these in prompt length.
|
101
101
|
sys.ps1 = "\001" + WHITE + "\002" + ">>> " + "\001" + RESET + "\002"
|
102
102
|
sys.ps2 = "\001" + WHITE + "\002" + "... " + "\001" + RESET + "\002"
|
103
103
|
|
104
|
-
# Replace sys.stdout with
|
104
|
+
# Replace sys.stdout with BlueStdout to ensure all output is printed in blue.
|
105
105
|
sys.stdout = BlueStdout(sys.__stdout__)
|
106
106
|
|
107
|
-
# Create our custom interactive console
|
107
|
+
# Create our custom interactive console.
|
108
108
|
console = ColorInteractiveConsole(locals=local_vars)
|
109
109
|
|
110
|
-
# The banner is
|
110
|
+
# The welcome banner is explicitly wrapped in BLUE and RESET.
|
111
111
|
banner = (BLUE +
|
112
112
|
"Welcome to the rgwfuncs interactive shell.\n"
|
113
113
|
"Use up/down arrows for command history.\n"
|
114
114
|
"Type 'exit()' or Ctrl+D to quit." +
|
115
115
|
RESET)
|
116
|
-
exitmsg = "Goodbye."
|
117
116
|
|
117
|
+
# Call interact with an empty exit message.
|
118
118
|
try:
|
119
|
-
console.interact(banner=banner)
|
120
|
-
|
121
|
-
|
119
|
+
console.interact(banner=banner, exitmsg="")
|
120
|
+
except SystemExit:
|
121
|
+
pass
|
122
122
|
|
@@ -2,11 +2,11 @@ rgwfuncs/__init__.py,sha256=LSn54Tlyskcb6Wab_wUpPLB6UGMe5LdrB3GU88mDEbU,1712
|
|
2
2
|
rgwfuncs/algebra_lib.py,sha256=rKFITfpWfgdBswnbMUuS41XgndEt-jUVz2ObO_ik7eM,42234
|
3
3
|
rgwfuncs/df_lib.py,sha256=r6T-MwyDq9NAPW1Xf6NzSy7ZFicIKdemR-UKu6TZt5g,71111
|
4
4
|
rgwfuncs/docs_lib.py,sha256=i63NzX-V8cGhikYdtkRGAEe2VcuwpXxDUyTRa9xI7l8,1972
|
5
|
-
rgwfuncs/interactive_shell_lib.py,sha256=
|
5
|
+
rgwfuncs/interactive_shell_lib.py,sha256=F9Kul06SK-X1DxFpINDLEHFab7UaqFHgx2eYmdmMoOg,4393
|
6
6
|
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
7
|
-
rgwfuncs-0.0.
|
8
|
-
rgwfuncs-0.0.
|
9
|
-
rgwfuncs-0.0.
|
10
|
-
rgwfuncs-0.0.
|
11
|
-
rgwfuncs-0.0.
|
12
|
-
rgwfuncs-0.0.
|
7
|
+
rgwfuncs-0.0.89.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
|
8
|
+
rgwfuncs-0.0.89.dist-info/METADATA,sha256=hSQt4YxDQ3jJeLLznSLUSfj68LTLXtOPZbtX8NH8Wck,60288
|
9
|
+
rgwfuncs-0.0.89.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
rgwfuncs-0.0.89.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
+
rgwfuncs-0.0.89.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
+
rgwfuncs-0.0.89.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|