rgwfuncs 0.0.81__py3-none-any.whl → 0.0.83__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 +22 -17
- {rgwfuncs-0.0.81.dist-info → rgwfuncs-0.0.83.dist-info}/METADATA +1 -1
- {rgwfuncs-0.0.81.dist-info → rgwfuncs-0.0.83.dist-info}/RECORD +7 -7
- {rgwfuncs-0.0.81.dist-info → rgwfuncs-0.0.83.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.81.dist-info → rgwfuncs-0.0.83.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.81.dist-info → rgwfuncs-0.0.83.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.81.dist-info → rgwfuncs-0.0.83.dist-info}/top_level.txt +0 -0
@@ -26,33 +26,37 @@ class BlueStdout:
|
|
26
26
|
self.at_line_start = True
|
27
27
|
|
28
28
|
def write(self, s):
|
29
|
-
# If the
|
30
|
-
# assume it should be displayed as-is (the prompt will be white).
|
29
|
+
# If the text exactly matches one of our prompt strings, write it as-is.
|
31
30
|
if s == sys.ps1 or s == sys.ps2:
|
32
31
|
self.wrapped.write(s)
|
33
32
|
return
|
34
33
|
|
35
|
-
# Process
|
36
|
-
# (We only want to color “output”, not the prompt.)
|
34
|
+
# Process text, coloring new lines with blue.
|
37
35
|
lines = s.split('\n')
|
38
36
|
for i, line in enumerate(lines):
|
39
|
-
# Only prepend blue if we are at a new line.
|
40
37
|
if self.at_line_start and line:
|
41
38
|
self.wrapped.write(BLUE + line)
|
42
39
|
else:
|
43
40
|
self.wrapped.write(line)
|
44
|
-
# If this is not the last line, then the newline was in the string.
|
45
41
|
if i < len(lines) - 1:
|
46
|
-
self.wrapped.write('\n' + RESET)
|
42
|
+
self.wrapped.write('\n' + RESET)
|
47
43
|
self.at_line_start = True
|
48
44
|
else:
|
49
|
-
# If the last chunk is non-empty, we are in the middle of a line.
|
50
45
|
self.at_line_start = (line == "")
|
51
|
-
|
52
|
-
|
46
|
+
|
53
47
|
def flush(self):
|
54
48
|
self.wrapped.flush()
|
55
49
|
|
50
|
+
def isatty(self):
|
51
|
+
return self.wrapped.isatty()
|
52
|
+
|
53
|
+
def fileno(self):
|
54
|
+
return self.wrapped.fileno()
|
55
|
+
|
56
|
+
def __getattr__(self, attr):
|
57
|
+
# Delegate any other attribute accesses to the wrapped stdout.
|
58
|
+
return getattr(self.wrapped, attr)
|
59
|
+
|
56
60
|
def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
57
61
|
"""
|
58
62
|
Launches an interactive prompt for inspecting and modifying local variables,
|
@@ -77,16 +81,17 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
77
81
|
if not isinstance(local_vars, dict):
|
78
82
|
raise TypeError("local_vars must be a dictionary")
|
79
83
|
|
80
|
-
# Set up readline history and completion
|
84
|
+
# Set up readline history and completion.
|
81
85
|
setup_readline()
|
82
86
|
|
83
|
-
# Make imported functions available in the REPL
|
87
|
+
# Make imported functions available in the REPL.
|
84
88
|
local_vars.update(globals())
|
85
89
|
|
86
|
-
#
|
87
|
-
# The
|
88
|
-
|
89
|
-
sys.
|
90
|
+
# Correctly wrap ANSI codes in the prompt strings.
|
91
|
+
# The \001 and \002 around the color codes tell readline that those characters
|
92
|
+
# have zero width.
|
93
|
+
sys.ps1 = "\001" + WHITE + "\002" + ">>> " + "\001" + RESET + "\002"
|
94
|
+
sys.ps2 = "\001" + WHITE + "\002" + "... " + "\001" + RESET + "\002"
|
90
95
|
|
91
96
|
# Wrap sys.stdout to emit blue-colored output.
|
92
97
|
sys.stdout = BlueStdout(sys.stdout)
|
@@ -94,7 +99,7 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
|
94
99
|
# Create an interactive console with the provided locals.
|
95
100
|
console = code.InteractiveConsole(locals=local_vars)
|
96
101
|
|
97
|
-
# Custom banner and exit message
|
102
|
+
# Custom banner and exit message.
|
98
103
|
banner = ("Welcome to the rgwfuncs interactive shell.\n"
|
99
104
|
"Use up/down arrows for command history.\n"
|
100
105
|
"Type 'exit()' or Ctrl+D to quit.")
|
@@ -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=41gZn25gds5Wlqf_AVvMe2SZRdTP1jjsLc1hrPYSocU,3708
|
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.83.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
|
8
|
+
rgwfuncs-0.0.83.dist-info/METADATA,sha256=mo8XbCW2vv8AYoNlWedCxLaYhMdtIch312ZehLWfUZM,60288
|
9
|
+
rgwfuncs-0.0.83.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
rgwfuncs-0.0.83.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
+
rgwfuncs-0.0.83.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
+
rgwfuncs-0.0.83.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|