rgwfuncs 0.0.78__py3-none-any.whl → 0.0.79__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.
@@ -2,23 +2,41 @@ import os
2
2
  import atexit
3
3
  import code
4
4
  import readline # Assuming this is imported elsewhere in your module
5
+ import sys
5
6
  from typing import Dict, Any
6
7
  from .df_lib import * # noqa: F401, F403, E402
7
8
  from .algebra_lib import * # noqa: F401, F403, E402
8
9
  from .str_lib import * # noqa: F401, F403, E402
9
10
  from .docs_lib import * # noqa: F401, F403, E402
10
11
 
11
- def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[97m') -> None:
12
+ class CustomConsole(code.InteractiveConsole):
13
+ """Custom console to make user input white while keeping prompts and output default."""
14
+ def raw_input(self, prompt=""):
15
+ # Print the prompt (>>>), then switch to white for input
16
+ sys.stdout.write(prompt) # Prompt in default color
17
+ sys.stdout.write("\033[97m") # Switch to white for input
18
+ sys.stdout.flush()
19
+ try:
20
+ line = input() # User types in white
21
+ except EOFError:
22
+ raise # Handle Ctrl+D gracefully
23
+ finally:
24
+ sys.stdout.write("\033[0m") # Reset to default after input
25
+ sys.stdout.flush()
26
+ return line
27
+
28
+ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '') -> None:
12
29
  """
13
30
  Launches an interactive prompt for inspecting and modifying local variables, making all methods
14
31
  in the rgwfuncs library available by default. Persists command history across sessions.
32
+ User input is displayed in white; other text uses the terminal's default color.
15
33
 
16
34
  Parameters:
17
35
  local_vars (dict): Dictionary of local variables to be available in the interactive shell.
18
- shell_color (str): ANSI color code for shell output (default: bright white '\033[97m').
36
+ shell_color (str): ANSI color code for shell output (default: empty for terminal default).
19
37
  """
20
38
 
21
- def setup_readline(shell_color: str = '\033[97m') -> None:
39
+ def setup_readline(shell_color: str = '') -> None:
22
40
  """Set up readline for history persistence with a given shell color."""
23
41
  HISTORY_FILE = os.path.expanduser("~/.rgwfuncs_shell_history")
24
42
  readline.set_history_length(1000)
@@ -27,7 +45,7 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[97m')
27
45
  try:
28
46
  readline.read_history_file(HISTORY_FILE)
29
47
  except Exception as e:
30
- print(f"{shell_color}Warning: Could not load history file: {e}\033[0m")
48
+ print(f"{shell_color}Warning: Could not load history file: {e}")
31
49
  atexit.register(readline.write_history_file, HISTORY_FILE)
32
50
 
33
51
  if not isinstance(local_vars, dict):
@@ -39,16 +57,16 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[97m')
39
57
  # Make imported functions available in the REPL
40
58
  local_vars.update(globals())
41
59
 
42
- # Create interactive console with local context
43
- console = code.InteractiveConsole(locals=local_vars)
60
+ # Set prompt to plain text (no color)
61
+ sys.ps1 = ">>> "
44
62
 
45
- # Set the prompt to white explicitly
46
- import sys
47
- sys.ps1 = f"\033[97m>>> " # White prompt
63
+ # Create custom console with local context
64
+ console = CustomConsole(locals=local_vars)
48
65
 
49
- # Start interactive session with a custom banner and exit message
50
- banner = f"{shell_color}Welcome to the rgwfuncs interactive shell.\nUse up/down arrows for command history.\nType 'exit()' or Ctrl+D to quit.\033[0m"
51
- exitmsg = f"{shell_color}Goodbye.\033[0m"
66
+ # Start interactive session with a custom banner and exit message in default color
67
+ banner = f"{shell_color}Welcome to the rgwfuncs interactive shell.\nUse up/down arrows for command history.\nType 'exit()' or Ctrl+D to quit."
68
+ exitmsg = f"{shell_color}Goodbye."
52
69
 
53
- # Run the interactive session without modifying sys.stdout
70
+ # Run the interactive session
54
71
  console.interact(banner=banner, exitmsg=exitmsg)
72
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.78
3
+ Version: 0.0.79
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=VkhhFRD2dMof9rk_LzW9qO3hcoN9H7CmXD5SRZx0vO0,2316
5
+ rgwfuncs/interactive_shell_lib.py,sha256=Pdujo-XdtfnCpudzHz0jSnYes0hNbHfPpREu4Fq1K0M,2979
6
6
  rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
7
- rgwfuncs-0.0.78.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
- rgwfuncs-0.0.78.dist-info/METADATA,sha256=-AkEFWXGxxs3hSb_-CAPXKoTsYNsvWdLssecL69lPaM,60288
9
- rgwfuncs-0.0.78.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- rgwfuncs-0.0.78.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
- rgwfuncs-0.0.78.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
- rgwfuncs-0.0.78.dist-info/RECORD,,
7
+ rgwfuncs-0.0.79.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
+ rgwfuncs-0.0.79.dist-info/METADATA,sha256=gTXvRXdi0hv7sSEW8TQIZdAHL0nrgtFx7kskQyL2FpM,60288
9
+ rgwfuncs-0.0.79.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ rgwfuncs-0.0.79.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
+ rgwfuncs-0.0.79.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
+ rgwfuncs-0.0.79.dist-info/RECORD,,