rgwfuncs 0.0.73__py3-none-any.whl → 0.0.74__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 +30 -7
- {rgwfuncs-0.0.73.dist-info → rgwfuncs-0.0.74.dist-info}/METADATA +1 -1
- {rgwfuncs-0.0.73.dist-info → rgwfuncs-0.0.74.dist-info}/RECORD +7 -7
- {rgwfuncs-0.0.73.dist-info → rgwfuncs-0.0.74.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.73.dist-info → rgwfuncs-0.0.74.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.73.dist-info → rgwfuncs-0.0.74.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.73.dist-info → rgwfuncs-0.0.74.dist-info}/top_level.txt +0 -0
@@ -15,10 +15,11 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[94m')
|
|
15
15
|
"""
|
16
16
|
Launches an interactive prompt for inspecting and modifying local variables, making all methods
|
17
17
|
in the rgwfuncs library available by default. Persists command history across sessions.
|
18
|
+
User input is displayed in white, while shell output uses the specified color.
|
18
19
|
|
19
20
|
Parameters:
|
20
21
|
local_vars (dict): Dictionary of local variables to be available in the interactive shell.
|
21
|
-
shell_color (str): ANSI color code for shell output (default:
|
22
|
+
shell_color (str): ANSI color code for shell output (default: blue '\033[94m').
|
22
23
|
"""
|
23
24
|
|
24
25
|
def setup_readline(shell_color: str = '\033[94m') -> None:
|
@@ -30,9 +31,30 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[94m')
|
|
30
31
|
try:
|
31
32
|
readline.read_history_file(HISTORY_FILE)
|
32
33
|
except Exception as e:
|
33
|
-
print(f"{shell_color}Warning: Could not load history file: {e}\033[
|
34
|
+
print(f"{shell_color}Warning: Could not load history file: {e}\033[0m")
|
34
35
|
atexit.register(readline.write_history_file, HISTORY_FILE)
|
35
36
|
|
37
|
+
class ColoredConsole(code.InteractiveConsole):
|
38
|
+
"""Custom console to handle colored output while keeping input white."""
|
39
|
+
def __init__(self, locals=None, shell_color='\033[94m'):
|
40
|
+
super().__init__(locals)
|
41
|
+
self.shell_color = shell_color
|
42
|
+
self.reset_color = '\033[0m'
|
43
|
+
self.input_color = '\033[97m' # Bright white for input
|
44
|
+
|
45
|
+
def write(self, data):
|
46
|
+
"""Write output with shell color."""
|
47
|
+
sys.stdout.write(f"{self.shell_color}{data}{self.reset_color}")
|
48
|
+
sys.stdout.flush()
|
49
|
+
|
50
|
+
def raw_input(self, prompt=""):
|
51
|
+
"""Get input with white color."""
|
52
|
+
sys.stdout.write(f"{self.shell_color}{prompt}{self.input_color}")
|
53
|
+
sys.stdout.flush()
|
54
|
+
line = input()
|
55
|
+
sys.stdout.write(self.reset_color)
|
56
|
+
return line
|
57
|
+
|
36
58
|
if not isinstance(local_vars, dict):
|
37
59
|
raise TypeError("local_vars must be a dictionary")
|
38
60
|
|
@@ -42,12 +64,13 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[94m')
|
|
42
64
|
# Make imported functions available in the REPL
|
43
65
|
local_vars.update(globals())
|
44
66
|
|
45
|
-
# Create interactive console with local context
|
46
|
-
console =
|
67
|
+
# Create interactive console with local context and custom coloring
|
68
|
+
console = ColoredConsole(locals=local_vars, shell_color=shell_color)
|
47
69
|
|
48
70
|
# Start interactive session with a custom banner and exit message
|
49
|
-
banner = f"{shell_color}Welcome to the rgwfuncs interactive shell.\nUse up/down arrows for command history.\nType 'exit()' or Ctrl+D to quit
|
50
|
-
exitmsg = f"{shell_color}Goodbye
|
71
|
+
banner = f"{shell_color}Welcome to the rgwfuncs interactive shell.\nUse up/down arrows for command history.\nType 'exit()' or Ctrl+D to quit.{shell_color}"
|
72
|
+
exitmsg = f"{shell_color}Goodbye.{shell_color}"
|
51
73
|
|
52
|
-
# Run the interactive session
|
74
|
+
# Run the interactive session
|
53
75
|
console.interact(banner=banner, exitmsg=exitmsg)
|
76
|
+
|
@@ -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=y3wSAOPO3qsA4HZ7xAtW8HimM8w-c8hjcEzMRLJ96ao,1960
|
5
|
-
rgwfuncs/interactive_shell_lib.py,sha256=
|
5
|
+
rgwfuncs/interactive_shell_lib.py,sha256=9DX_7YvDd8x2N05P0rVmEDJOGCfwnHWLV1w1HsP68uw,3201
|
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.74.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
|
8
|
+
rgwfuncs-0.0.74.dist-info/METADATA,sha256=6VAr3ZNhUdqNBN8kMQKes9AmZcDBUHAFUdLClYvZyRQ,60288
|
9
|
+
rgwfuncs-0.0.74.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
rgwfuncs-0.0.74.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
+
rgwfuncs-0.0.74.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
+
rgwfuncs-0.0.74.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|