rgwfuncs 0.0.86__py3-none-any.whl → 0.0.87__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/docs_lib.py +1 -0
- rgwfuncs/interactive_shell_lib.py +18 -16
- {rgwfuncs-0.0.86.dist-info → rgwfuncs-0.0.87.dist-info}/METADATA +1 -1
- rgwfuncs-0.0.87.dist-info/RECORD +12 -0
- rgwfuncs-0.0.86.dist-info/RECORD +0 -12
- {rgwfuncs-0.0.86.dist-info → rgwfuncs-0.0.87.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.86.dist-info → rgwfuncs-0.0.87.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.86.dist-info → rgwfuncs-0.0.87.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.86.dist-info → rgwfuncs-0.0.87.dist-info}/top_level.txt +0 -0
rgwfuncs/docs_lib.py
CHANGED
@@ -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 each new prompt,
|
18
|
+
and the welcome banner is in blue.
|
19
19
|
|
20
|
-
local_vars: dictionary of local variables
|
20
|
+
local_vars: dictionary of local variables available to the interactive shell.
|
21
21
|
"""
|
22
22
|
|
23
23
|
# ANSI color escape codes.
|
@@ -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: wrapper for stdout to output text 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 s matches our prompt strings, write
|
47
|
+
# If s matches our prompt strings, write it as-is.
|
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 so each new line is colored.
|
52
52
|
lines = s.split('\n')
|
53
53
|
for i, line in enumerate(lines):
|
54
54
|
if self.at_line_start and line:
|
@@ -73,15 +73,13 @@ 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 InteractiveConsole to restore the original
|
77
|
-
# stdout during input, and print
|
76
|
+
# ColorInteractiveConsole: subclass InteractiveConsole to temporarily restore the original
|
77
|
+
# stdout during input, and print a 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 newline before the prompt.
|
84
|
-
print("")
|
85
83
|
line = input(prompt)
|
86
84
|
except EOFError:
|
87
85
|
raise
|
@@ -89,28 +87,32 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
89
87
|
sys.stdout = saved_stdout
|
90
88
|
return line
|
91
89
|
|
92
|
-
#
|
90
|
+
# Ensure local_vars is a dictionary.
|
93
91
|
if not isinstance(local_vars, dict):
|
94
92
|
raise TypeError("local_vars must be a dictionary")
|
95
93
|
|
94
|
+
# Setup readline for history and completion.
|
96
95
|
setup_readline()
|
97
96
|
|
98
97
|
# Merge globals into local_vars.
|
99
98
|
local_vars.update(globals())
|
100
99
|
|
101
|
-
# Wrap ANSI
|
100
|
+
# Wrap ANSI escape codes with markers so that readline ignores them in prompt length.
|
102
101
|
sys.ps1 = "\001" + WHITE + "\002" + ">>> " + "\001" + RESET + "\002"
|
103
102
|
sys.ps2 = "\001" + WHITE + "\002" + "... " + "\001" + RESET + "\002"
|
104
103
|
|
105
|
-
#
|
104
|
+
# Replace sys.stdout with our BlueStdout to globally paint output.
|
106
105
|
sys.stdout = BlueStdout(sys.__stdout__)
|
107
106
|
|
108
|
-
# Create
|
107
|
+
# Create our custom interactive console using the modified locals.
|
109
108
|
console = ColorInteractiveConsole(locals=local_vars)
|
110
109
|
|
111
|
-
banner
|
110
|
+
# The banner is now explicitly wrapped in BLUE and RESET so it prints in blue.
|
111
|
+
banner = (BLUE +
|
112
|
+
"Welcome to the rgwfuncs interactive shell.\n"
|
112
113
|
"Use up/down arrows for command history.\n"
|
113
|
-
"Type 'exit()' or Ctrl+D to quit."
|
114
|
+
"Type 'exit()' or Ctrl+D to quit." +
|
115
|
+
RESET)
|
114
116
|
exitmsg = "Goodbye."
|
115
117
|
|
116
118
|
try:
|
@@ -0,0 +1,12 @@
|
|
1
|
+
rgwfuncs/__init__.py,sha256=LSn54Tlyskcb6Wab_wUpPLB6UGMe5LdrB3GU88mDEbU,1712
|
2
|
+
rgwfuncs/algebra_lib.py,sha256=rKFITfpWfgdBswnbMUuS41XgndEt-jUVz2ObO_ik7eM,42234
|
3
|
+
rgwfuncs/df_lib.py,sha256=r6T-MwyDq9NAPW1Xf6NzSy7ZFicIKdemR-UKu6TZt5g,71111
|
4
|
+
rgwfuncs/docs_lib.py,sha256=i63NzX-V8cGhikYdtkRGAEe2VcuwpXxDUyTRa9xI7l8,1972
|
5
|
+
rgwfuncs/interactive_shell_lib.py,sha256=KnGb3JgMH1B3JFfxWAzcTZUveQO63l_Gd1lHulEHm0g,4375
|
6
|
+
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
7
|
+
rgwfuncs-0.0.87.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
|
8
|
+
rgwfuncs-0.0.87.dist-info/METADATA,sha256=OIhgNbvYN8PewH9ESzS_A8n-L7HsCh13f_zoQdPntEM,60288
|
9
|
+
rgwfuncs-0.0.87.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
rgwfuncs-0.0.87.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
+
rgwfuncs-0.0.87.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
+
rgwfuncs-0.0.87.dist-info/RECORD,,
|
rgwfuncs-0.0.86.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
rgwfuncs/__init__.py,sha256=LSn54Tlyskcb6Wab_wUpPLB6UGMe5LdrB3GU88mDEbU,1712
|
2
|
-
rgwfuncs/algebra_lib.py,sha256=rKFITfpWfgdBswnbMUuS41XgndEt-jUVz2ObO_ik7eM,42234
|
3
|
-
rgwfuncs/df_lib.py,sha256=r6T-MwyDq9NAPW1Xf6NzSy7ZFicIKdemR-UKu6TZt5g,71111
|
4
|
-
rgwfuncs/docs_lib.py,sha256=y3wSAOPO3qsA4HZ7xAtW8HimM8w-c8hjcEzMRLJ96ao,1960
|
5
|
-
rgwfuncs/interactive_shell_lib.py,sha256=rebSWi6L8akWA9LlQXjv9jlG2VoT9B8PqgCB4Oz9hEc,4177
|
6
|
-
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
7
|
-
rgwfuncs-0.0.86.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
|
8
|
-
rgwfuncs-0.0.86.dist-info/METADATA,sha256=pY5udapgOBioWgi1uxLFdPyGIxj9q9BRioqVxZzLYlI,60288
|
9
|
-
rgwfuncs-0.0.86.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
-
rgwfuncs-0.0.86.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
-
rgwfuncs-0.0.86.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
-
rgwfuncs-0.0.86.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|