rgwfuncs 0.0.96__py3-none-any.whl → 0.0.98__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.
rgwfuncs/df_lib.py CHANGED
@@ -318,7 +318,7 @@ def load_data_from_query(db_preset_name: str, query: str, config: Optional[Union
318
318
  db_preset_name: The name of the database preset in the configuration file.
319
319
  query: The SQL query to execute.
320
320
  config (Optional[Union[str, dict]], optional): Configuration source. Can be:
321
- - None: Uses default path '~/.rgwfuncsrc'
321
+ - None: Searches for '.rgwfuncsrc' in current directory and upwards
322
322
  - str: Path to a JSON configuration file
323
323
  - dict: Direct configuration dictionary
324
324
 
@@ -326,21 +326,33 @@ def load_data_from_query(db_preset_name: str, query: str, config: Optional[Union
326
326
  A DataFrame containing the query result.
327
327
 
328
328
  Raises:
329
- FileNotFoundError: If the configuration file is not found.
329
+ FileNotFoundError: If no '.rgwfuncsrc' file is found after traversing all parent directories.
330
330
  ValueError: If the database preset or db_type is invalid.
331
331
  """
332
332
 
333
333
  def get_config(config: Optional[Union[str, dict]] = None) -> dict:
334
- """Get telegram configuration either from a path or direct dictionary."""
334
+ """Get configuration either from a path, direct dictionary, or by searching upwards."""
335
335
  def get_config_from_file(config_path: str) -> dict:
336
336
  """Load configuration from a JSON file."""
337
337
  with open(config_path, 'r') as file:
338
338
  return json.load(file)
339
339
 
340
+ def find_config_file() -> str:
341
+ """Search for '.rgwfuncsrc' in current directory and upwards."""
342
+ current_dir = os.getcwd()
343
+ while True:
344
+ config_path = os.path.join(current_dir, '.rgwfuncsrc')
345
+ if os.path.isfile(config_path):
346
+ return config_path
347
+ parent_dir = os.path.dirname(current_dir)
348
+ if parent_dir == current_dir: # Reached root directory
349
+ raise FileNotFoundError("No '.rgwfuncsrc' file found in current or parent directories")
350
+ current_dir = parent_dir
351
+
340
352
  # Determine the config to use
341
353
  if config is None:
342
- # Default to ~/.rgwfuncsrc if no config provided
343
- config_path = os.path.expanduser('~/.rgwfuncsrc')
354
+ # Search for .rgwfuncsrc upwards from current directory
355
+ config_path = find_config_file()
344
356
  return get_config_from_file(config_path)
345
357
  elif isinstance(config, str):
346
358
  # If config is a string, treat it as a path and load it
rgwfuncs/str_lib.py CHANGED
@@ -16,25 +16,38 @@ def send_telegram_message(preset_name: str, message: str, config: Optional[Union
16
16
  preset_name (str): The name of the preset to use for sending the message.
17
17
  message (str): The message to send.
18
18
  config (Optional[Union[str, dict]], optional): Configuration source. Can be:
19
- - None: Uses default path '~/.rgwfuncsrc'
19
+ - None: Searches for '.rgwfuncsrc' in current directory and upwards
20
20
  - str: Path to a JSON configuration file
21
21
  - dict: Direct configuration dictionary
22
22
 
23
23
  Raises:
24
+ FileNotFoundError: If no '.rgwfuncsrc' file is found after traversing all parent directories.
24
25
  RuntimeError: If the preset is not found or necessary details are missing.
26
+ ValueError: If the config parameter is neither a path string nor a dictionary.
25
27
  """
26
-
27
28
  def get_config(config: Optional[Union[str, dict]] = None) -> dict:
28
- """Get telegram configuration either from a path or direct dictionary."""
29
+ """Get configuration either from a path, direct dictionary, or by searching upwards."""
29
30
  def get_config_from_file(config_path: str) -> dict:
30
31
  """Load configuration from a JSON file."""
31
32
  with open(config_path, 'r') as file:
32
33
  return json.load(file)
33
34
 
35
+ def find_config_file() -> str:
36
+ """Search for '.rgwfuncsrc' in current directory and upwards."""
37
+ current_dir = os.getcwd()
38
+ while True:
39
+ config_path = os.path.join(current_dir, '.rgwfuncsrc')
40
+ if os.path.isfile(config_path):
41
+ return config_path
42
+ parent_dir = os.path.dirname(current_dir)
43
+ if parent_dir == current_dir: # Reached root directory
44
+ raise FileNotFoundError("No '.rgwfuncsrc' file found in current or parent directories")
45
+ current_dir = parent_dir
46
+
34
47
  # Determine the config to use
35
48
  if config is None:
36
- # Default to ~/.rgwfuncsrc if no config provided
37
- config_path = os.path.expanduser('~/.rgwfuncsrc')
49
+ # Search for .rgwfuncsrc upwards from current directory
50
+ config_path = find_config_file()
38
51
  return get_config_from_file(config_path)
39
52
  elif isinstance(config, str):
40
53
  # If config is a string, treat it as a path and load it
@@ -53,8 +66,7 @@ def send_telegram_message(preset_name: str, message: str, config: Optional[Union
53
66
  return preset
54
67
  return None
55
68
 
56
- def get_telegram_bot_details(
57
- config: dict, preset_name: str) -> Tuple[str, str]:
69
+ def get_telegram_bot_details(config: dict, preset_name: str) -> Tuple[str, str]:
58
70
  """Retrieve the Telegram bot token and chat ID from the preset."""
59
71
  preset = get_telegram_preset(config, preset_name)
60
72
  if not preset:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rgwfuncs
3
- Version: 0.0.96
3
+ Version: 0.0.98
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
@@ -0,0 +1,12 @@
1
+ rgwfuncs/__init__.py,sha256=LSn54Tlyskcb6Wab_wUpPLB6UGMe5LdrB3GU88mDEbU,1712
2
+ rgwfuncs/algebra_lib.py,sha256=rKFITfpWfgdBswnbMUuS41XgndEt-jUVz2ObO_ik7eM,42234
3
+ rgwfuncs/df_lib.py,sha256=3foomRHlunCpf_accTcqfdgwDmSPIVkVCnlWJ4ag4XQ,76947
4
+ rgwfuncs/docs_lib.py,sha256=i63NzX-V8cGhikYdtkRGAEe2VcuwpXxDUyTRa9xI7l8,1972
5
+ rgwfuncs/interactive_shell_lib.py,sha256=YN0ZnM5twIsOeDKuOQ9ZGURCvvBX0RZjM4a1vO1C3E8,4281
6
+ rgwfuncs/str_lib.py,sha256=Nho_MrRquDkgQL96huj8sw3OF2S6LCOwGsS_gd9h7lo,4029
7
+ rgwfuncs-0.0.98.dist-info/licenses/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
+ rgwfuncs-0.0.98.dist-info/METADATA,sha256=XMYT6VoBy7sxoBlz4ReNZA1iENAnKQSSdHuAx3E5Gqk,62223
9
+ rgwfuncs-0.0.98.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
10
+ rgwfuncs-0.0.98.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
+ rgwfuncs-0.0.98.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
+ rgwfuncs-0.0.98.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- rgwfuncs/__init__.py,sha256=LSn54Tlyskcb6Wab_wUpPLB6UGMe5LdrB3GU88mDEbU,1712
2
- rgwfuncs/algebra_lib.py,sha256=rKFITfpWfgdBswnbMUuS41XgndEt-jUVz2ObO_ik7eM,42234
3
- rgwfuncs/df_lib.py,sha256=QgEydReadUBbBkyWGaDfB_OjtALGdjKmzp_S9YZlUks,76266
4
- rgwfuncs/docs_lib.py,sha256=i63NzX-V8cGhikYdtkRGAEe2VcuwpXxDUyTRa9xI7l8,1972
5
- rgwfuncs/interactive_shell_lib.py,sha256=YN0ZnM5twIsOeDKuOQ9ZGURCvvBX0RZjM4a1vO1C3E8,4281
6
- rgwfuncs/str_lib.py,sha256=hE0VfP6rhQpczsKyCZvH3G1aMRwngKnkW3NTYCEc0Po,3208
7
- rgwfuncs-0.0.96.dist-info/licenses/LICENSE,sha256=jLvt20gcUZYB8UOvyBvyKQ1qhYYhD__qP7ZDx2lPFkU,1062
8
- rgwfuncs-0.0.96.dist-info/METADATA,sha256=s2T3236W7cPHPnCM8dsFHk238-BIfncEBpzjVDToBwc,62223
9
- rgwfuncs-0.0.96.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
10
- rgwfuncs-0.0.96.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
11
- rgwfuncs-0.0.96.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
12
- rgwfuncs-0.0.96.dist-info/RECORD,,