rgwfuncs 0.0.87__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.87
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.87"
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.87
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
@@ -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 white prompt. An extra blank line appears before each new prompt,
18
- and the welcome banner is in blue.
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 available to 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: wrapper for stdout to output text 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 it as-is.
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
- # Process output line by line so each new line is colored.
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,13 +73,15 @@ 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 temporarily restore the original
77
- # stdout during input, and print a 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 blank line before the prompt.
84
+ print("")
83
85
  line = input(prompt)
84
86
  except EOFError:
85
87
  raise
@@ -91,32 +93,32 @@ def interactive_shell(local_vars: Dict[str, Any]) -> None:
91
93
  if not isinstance(local_vars, dict):
92
94
  raise TypeError("local_vars must be a dictionary")
93
95
 
94
- # Setup readline for history and completion.
96
+ # Initialize readline history.
95
97
  setup_readline()
96
98
 
97
99
  # Merge globals into local_vars.
98
100
  local_vars.update(globals())
99
101
 
100
- # Wrap ANSI escape codes with markers so that readline ignores them in prompt length.
102
+ # Wrap ANSI escape codes with markers (\001 and \002) so readline ignores these in prompt length.
101
103
  sys.ps1 = "\001" + WHITE + "\002" + ">>> " + "\001" + RESET + "\002"
102
104
  sys.ps2 = "\001" + WHITE + "\002" + "... " + "\001" + RESET + "\002"
103
105
 
104
- # Replace sys.stdout with our BlueStdout to globally paint output.
106
+ # Replace sys.stdout with BlueStdout to ensure all output is printed in blue.
105
107
  sys.stdout = BlueStdout(sys.__stdout__)
106
108
 
107
- # Create our custom interactive console using the modified locals.
109
+ # Create our custom interactive console.
108
110
  console = ColorInteractiveConsole(locals=local_vars)
109
111
 
110
- # The banner is now explicitly wrapped in BLUE and RESET so it prints in blue.
112
+ # The welcome banner is explicitly wrapped in BLUE and RESET.
111
113
  banner = (BLUE +
112
114
  "Welcome to the rgwfuncs interactive shell.\n"
113
115
  "Use up/down arrows for command history.\n"
114
116
  "Type 'exit()' or Ctrl+D to quit." +
115
117
  RESET)
116
- exitmsg = "Goodbye."
117
118
 
119
+ # Call interact with an empty exit message.
118
120
  try:
119
- console.interact(banner=banner)
120
- finally:
121
- print(exitmsg)
121
+ console.interact(banner=banner, exitmsg="")
122
+ except SystemExit:
123
+ pass
122
124
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.87
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