rgwfuncs 0.0.85__py3-none-any.whl → 0.0.86__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.
@@ -14,9 +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 a custom blue output and white prompt. All helper definitions are nested within.
17
+ with blue-colored output and a prompt in white. An extra blank line is inserted
18
+ before each new input prompt.
18
19
 
19
- local_vars: dictionary with local variables to be available in the interactive shell.
20
+ local_vars: dictionary of local variables to be available in the interactive shell.
20
21
  """
21
22
 
22
23
  # ANSI color escape codes.
@@ -24,7 +25,7 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
24
25
  WHITE = "\033[37m"
25
26
  RESET = "\033[0m"
26
27
 
27
- # Helper: setup readline for history persistence.
28
+ # Function to set up readline history.
28
29
  def setup_readline() -> None:
29
30
  HISTORY_FILE = os.path.expanduser("~/.rgwfuncs_shell_history")
30
31
  readline.set_history_length(1000)
@@ -36,18 +37,18 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
36
37
  print(f"Warning: Could not load history file: {e}")
37
38
  atexit.register(readline.write_history_file, HISTORY_FILE)
38
39
 
39
- # Nested BlueStdout: a wrapper for sys.stdout that prepends blue color on output.
40
+ # BlueStdout: wrap stdout so output is printed in blue.
40
41
  class BlueStdout:
41
42
  def __init__(self, wrapped):
42
43
  self.wrapped = wrapped
43
44
  self.at_line_start = True
44
45
 
45
46
  def write(self, s):
46
- # Do not interfere with the prompt strings.
47
+ # If s matches our prompt strings, write verbatim.
47
48
  if s == sys.ps1 or s == sys.ps2:
48
49
  self.wrapped.write(s)
49
50
  return
50
- # Process output line by line.
51
+ # Write each new line in blue.
51
52
  lines = s.split('\n')
52
53
  for i, line in enumerate(lines):
53
54
  if self.at_line_start and line:
@@ -72,13 +73,15 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
72
73
  def __getattr__(self, attr):
73
74
  return getattr(self.wrapped, attr)
74
75
 
75
- # Nested ColorInteractiveConsole: a subclass of InteractiveConsole that temporarily
76
- # restores the original stdout when reading input so that readline functions properly.
76
+ # ColorInteractiveConsole: subclass InteractiveConsole to restore the original
77
+ # stdout during input, and print an extra blank line before each prompt.
77
78
  class ColorInteractiveConsole(code.InteractiveConsole):
78
79
  def raw_input(self, prompt=""):
79
80
  saved_stdout = sys.stdout
80
81
  sys.stdout = sys.__stdout__
81
82
  try:
83
+ # Print an extra newline before the prompt.
84
+ print("")
82
85
  line = input(prompt)
83
86
  except EOFError:
84
87
  raise
@@ -86,25 +89,23 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
86
89
  sys.stdout = saved_stdout
87
90
  return line
88
91
 
89
- # Ensure that the passed local_vars is a dictionary.
92
+ # Validate that local_vars is a dictionary.
90
93
  if not isinstance(local_vars, dict):
91
94
  raise TypeError("local_vars must be a dictionary")
92
95
 
93
- # Setup readline.
94
96
  setup_readline()
95
97
 
96
- # Make imported functions available in the REPL by merging globals.
98
+ # Merge globals into local_vars.
97
99
  local_vars.update(globals())
98
100
 
99
- # Wrap ANSI escape sequences in markers recognized by readline so that they do not count
100
- # toward the visible prompt length.
101
+ # Wrap ANSI color codes with markers for zero-width in the prompt.
101
102
  sys.ps1 = "\001" + WHITE + "\002" + ">>> " + "\001" + RESET + "\002"
102
103
  sys.ps2 = "\001" + WHITE + "\002" + "... " + "\001" + RESET + "\002"
103
104
 
104
- # Replace sys.stdout with our blue-printing wrapper.
105
+ # Use BlueStdout to wrap the original stdout.
105
106
  sys.stdout = BlueStdout(sys.__stdout__)
106
107
 
107
- # Instantiate our custom interactive console.
108
+ # Create the custom interactive console.
108
109
  console = ColorInteractiveConsole(locals=local_vars)
109
110
 
110
111
  banner = ("Welcome to the rgwfuncs interactive shell.\n"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.85
3
+ Version: 0.0.86
4
4
  Summary: A functional programming paradigm for mathematical modelling and data science
5
5
  Home-page: https://github.com/ryangerardwilson/rgwfunc
6
6
  Author: Ryan Gerard Wilson
@@ -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=zM4WrG425WK3MsPOfSgxvJxRJsUV177IYrSGvE-uAQE,4254
5
+ rgwfuncs/interactive_shell_lib.py,sha256=rebSWi6L8akWA9LlQXjv9jlG2VoT9B8PqgCB4Oz9hEc,4177
6
6
  rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
7
- rgwfuncs-0.0.85.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
- rgwfuncs-0.0.85.dist-info/METADATA,sha256=28YYKElMTP4Fm5TnxB8iU2F088nrhzQEg8YhM1XaoI4,60288
9
- rgwfuncs-0.0.85.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- rgwfuncs-0.0.85.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
- rgwfuncs-0.0.85.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
- rgwfuncs-0.0.85.dist-info/RECORD,,
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,,