rgwfuncs 0.0.87__tar.gz → 0.0.88__tar.gz
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-0.0.87/src/rgwfuncs.egg-info → rgwfuncs-0.0.88}/PKG-INFO +1 -1
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/pyproject.toml +1 -1
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/setup.cfg +1 -1
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs/interactive_shell_lib.py +20 -18
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88/src/rgwfuncs.egg-info}/PKG-INFO +1 -1
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/LICENSE +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/README.md +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs/__init__.py +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs/algebra_lib.py +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs/df_lib.py +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs/docs_lib.py +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs/str_lib.py +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs.egg-info/SOURCES.txt +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs.egg-info/dependency_links.txt +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs.egg-info/entry_points.txt +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs.egg-info/requires.txt +0 -0
- {rgwfuncs-0.0.87 → rgwfuncs-0.0.88}/src/rgwfuncs.egg-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,13 +73,15 @@ 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
|
81
81
|
sys.stdout = sys.__stdout__
|
82
82
|
try:
|
83
|
+
# Print an extra blank line before the prompt.
|
84
|
+
print("")
|
83
85
|
line = input(prompt)
|
84
86
|
except EOFError:
|
85
87
|
raise
|
@@ -91,32 +93,32 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
91
93
|
if not isinstance(local_vars, dict):
|
92
94
|
raise TypeError("local_vars must be a dictionary")
|
93
95
|
|
94
|
-
#
|
96
|
+
# Initialize readline history.
|
95
97
|
setup_readline()
|
96
98
|
|
97
99
|
# Merge globals into local_vars.
|
98
100
|
local_vars.update(globals())
|
99
101
|
|
100
|
-
# Wrap ANSI escape codes with markers so
|
102
|
+
# Wrap ANSI escape codes with markers (\001 and \002) so readline ignores these in prompt length.
|
101
103
|
sys.ps1 = "\001" + WHITE + "\002" + ">>> " + "\001" + RESET + "\002"
|
102
104
|
sys.ps2 = "\001" + WHITE + "\002" + "... " + "\001" + RESET + "\002"
|
103
105
|
|
104
|
-
# Replace sys.stdout with
|
106
|
+
# Replace sys.stdout with BlueStdout to ensure all output is printed in blue.
|
105
107
|
sys.stdout = BlueStdout(sys.__stdout__)
|
106
108
|
|
107
|
-
# Create our custom interactive console
|
109
|
+
# Create our custom interactive console.
|
108
110
|
console = ColorInteractiveConsole(locals=local_vars)
|
109
111
|
|
110
|
-
# The banner is
|
112
|
+
# The welcome banner is explicitly wrapped in BLUE and RESET.
|
111
113
|
banner = (BLUE +
|
112
114
|
"Welcome to the rgwfuncs interactive shell.\n"
|
113
115
|
"Use up/down arrows for command history.\n"
|
114
116
|
"Type 'exit()' or Ctrl+D to quit." +
|
115
117
|
RESET)
|
116
|
-
exitmsg = "Goodbye."
|
117
118
|
|
119
|
+
# Call interact with an empty exit message.
|
118
120
|
try:
|
119
|
-
console.interact(banner=banner)
|
120
|
-
|
121
|
-
|
121
|
+
console.interact(banner=banner, exitmsg="")
|
122
|
+
except SystemExit:
|
123
|
+
pass
|
122
124
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|