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