rgwfuncs 0.0.71__py3-none-any.whl → 0.0.73__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.
@@ -11,7 +11,7 @@ from .algebra_lib import * # noqa: F401, F403, E402
11
11
  from .str_lib import * # noqa: F401, F403, E402
12
12
  from .docs_lib import * # noqa: F401, F403, E402
13
13
 
14
- def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[37m') -> None:
14
+ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[94m') -> None:
15
15
  """
16
16
  Launches an interactive prompt for inspecting and modifying local variables, making all methods
17
17
  in the rgwfuncs library available by default. Persists command history across sessions.
@@ -21,25 +21,18 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[37m')
21
21
  shell_color (str): ANSI color code for shell output (default: non-bright white '\033[37m').
22
22
  """
23
23
 
24
- def setup_readline(shell_color: str = '\033[37m') -> None:
25
- """Set up readline for command history persistence with a given shell color."""
24
+ def setup_readline(shell_color: str = '\033[94m') -> None:
25
+ """Set up readline for history persistence with a given shell color."""
26
26
  HISTORY_FILE = os.path.expanduser("~/.rgwfuncs_shell_history")
27
- readline.set_history_length(1000) # Limit history to 1000 lines
28
- readline.parse_and_bind("tab: complete") # Enable tab completion
27
+ readline.set_history_length(1000)
28
+ readline.parse_and_bind("tab: complete")
29
29
  if os.path.exists(HISTORY_FILE):
30
30
  try:
31
31
  readline.read_history_file(HISTORY_FILE)
32
32
  except Exception as e:
33
- print(f"{shell_color}Warning: Could not load history file: {e}\033[0m")
33
+ print(f"{shell_color}Warning: Could not load history file: {e}\033[94m")
34
34
  atexit.register(readline.write_history_file, HISTORY_FILE)
35
35
 
36
- def colorize_output(text: str, shell_color: str) -> str:
37
- """Apply shell color only to text without ANSI codes, preserving existing codes."""
38
- # Split text into segments around ANSI escape sequences
39
- if '\x1b[' not in text and '\033[' not in text:
40
- return f"{shell_color}{text}\033[0m"
41
- return text # Return unchanged if it contains ANSI codes
42
-
43
36
  if not isinstance(local_vars, dict):
44
37
  raise TypeError("local_vars must be a dictionary")
45
38
 
@@ -53,25 +46,8 @@ def interactive_shell(local_vars: Dict[str, Any], shell_color: str = '\033[37m')
53
46
  console = code.InteractiveConsole(locals=local_vars)
54
47
 
55
48
  # Start interactive session with a custom banner and exit message
56
- 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"
57
- exitmsg = f"{shell_color}Goodbye.\033[0m"
58
-
59
- # Save original stdout write function
60
- original_write = sys.stdout.write
61
-
62
- # Define a custom write function that respects existing ANSI codes
63
- def colored_write(text: str) -> None:
64
- # Write the text as-is if it contains ANSI codes, otherwise apply shell_color
65
- colored_text = colorize_output(text, shell_color)
66
- original_write(colored_text)
67
-
68
- # Temporarily replace stdout.write
69
- sys.stdout.write = colored_write
70
-
71
- # Start the interactive session
72
- try:
73
- console.interact(banner=banner, exitmsg=exitmsg)
74
- finally:
75
- # Ensure original stdout.write is restored even on exceptions
76
- sys.stdout.write = original_write
49
+ 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[94m"
50
+ exitmsg = f"{shell_color}Goodbye.\033[94m"
77
51
 
52
+ # Run the interactive session without modifying sys.stdout
53
+ console.interact(banner=banner, exitmsg=exitmsg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.71
3
+ Version: 0.0.73
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=SsStlBx3vW6NE88m_reLCqhB7gVVi_fWilOkYKKxgEo,3259
5
+ rgwfuncs/interactive_shell_lib.py,sha256=kqIbn0lK8I1STskhHKvskuAFiey4m-VeUC1AB1GTPrU,2244
6
6
  rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
7
- rgwfuncs-0.0.71.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
- rgwfuncs-0.0.71.dist-info/METADATA,sha256=sVSS56mX9nGBL0lQVm6-RD0Zmo_aZqH1uBN6itkgfRc,60288
9
- rgwfuncs-0.0.71.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- rgwfuncs-0.0.71.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
- rgwfuncs-0.0.71.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
- rgwfuncs-0.0.71.dist-info/RECORD,,
7
+ rgwfuncs-0.0.73.dist-info/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
+ rgwfuncs-0.0.73.dist-info/METADATA,sha256=I603IiiXYUEOE5Yua14iyjPfyA_dluZKXHC7xsNQ2EQ,60288
9
+ rgwfuncs-0.0.73.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ rgwfuncs-0.0.73.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
+ rgwfuncs-0.0.73.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
+ rgwfuncs-0.0.73.dist-info/RECORD,,