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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.86
3
+ Version: 0.0.88
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rgwfuncs"
7
- version = "0.0.86"
7
+ version = "0.0.88"
8
8
  authors = [
9
9
  { name = "Ryan Gerard Wilson", email = "ryangerardwilson@gmail.com" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = rgwfuncs
3
- version = 0.0.86
3
+ version = 0.0.88
4
4
  author = Ryan Gerard Wilson
5
5
  author_email = ryangerardwilson@gmail.com
6
6
  description = A functional programming paradigm for mathematical modelling and data science
@@ -49,3 +49,4 @@ def docs(method_type_filter: Optional[str] = None) -> None:
49
49
  docstring: Optional[str] = functions[name].__doc__
50
50
  if docstring:
51
51
  print(f"\n{name}:\n{docstring}")
52
+ print()
@@ -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 in white. An extra blank line is inserted
18
- before each new input prompt.
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 local variables to be available in the interactive shell.
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
- # Function to set up readline history.
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: wrap stdout so output is printed in blue.
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 s matches our prompt strings, write verbatim.
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
- # Write each new line in blue.
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 InteractiveConsole to restore the original
77
- # stdout during input, and print an extra blank line before each prompt.
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 newline before the prompt.
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
- # Validate that local_vars is a dictionary.
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 color codes with markers for zero-width in the prompt.
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
- # Use BlueStdout to wrap the original stdout.
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 the custom interactive console.
109
+ # Create our custom interactive console.
109
110
  console = ColorInteractiveConsole(locals=local_vars)
110
111
 
111
- banner = ("Welcome to the rgwfuncs interactive shell.\n"
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
- exitmsg = "Goodbye."
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
- finally:
119
- print(exitmsg)
121
+ console.interact(banner=banner, exitmsg="")
122
+ except SystemExit:
123
+ pass
120
124
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.86
3
+ Version: 0.0.88
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
File without changes
File without changes