abstract-utilities 0.2.2.455__py3-none-any.whl → 0.2.2.456__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.

Potentially problematic release.


This version of abstract-utilities might be problematic. Click here for more details.

@@ -12,13 +12,16 @@ Usage:
12
12
  from abstract_utilities.read_write_utils import *
13
13
  """
14
14
 
15
- import os
15
+ import os, json
16
16
  from .ssh_utils.utils import run_cmd
17
17
  from .abstract_classes import run_pruned_func
18
18
  _FILE_PATH_KEYS = ['file', 'filepath', 'file_path', 'path', 'directory', 'f', 'dst', 'dest']
19
19
  _CONTENTS_KEYS = ['cont', 'content', 'contents', 'data', 'datas', 'dat', 'src', 'source']
20
20
 
21
21
 
22
+
23
+ META_SUFFIX = ".meta.json"
24
+
22
25
  # --- Helper utilities --------------------------------------------------------
23
26
  def string_in_keys(strings, kwargs):
24
27
  """Find a matching keyword in kwargs that contains any of the given substrings."""
@@ -74,12 +77,9 @@ def check_read_write_params(*args, **kwargs):
74
77
  return file_path, contents
75
78
 
76
79
 
77
- # --- Core functionality -------------------------------------------------------
78
80
  def write_to_file(*args, **kwargs):
79
81
  """
80
- Write contents to a file (create if missing).
81
-
82
- Returns the file_path written.
82
+ Write contents to a file and save optional metadata like user_at_host.
83
83
  """
84
84
  file_path, contents = check_read_write_params(*args, **kwargs)
85
85
  if contents is None:
@@ -88,7 +88,30 @@ def write_to_file(*args, **kwargs):
88
88
  os.makedirs(os.path.dirname(file_path) or ".", exist_ok=True)
89
89
  with open(file_path, "w", encoding="utf-8") as f:
90
90
  f.write(str(contents))
91
+
92
+ # Store user_at_host metadata if provided
93
+ user_at_host = kwargs.get("user_at_host")
94
+ if user_at_host:
95
+ meta_path = file_path + META_SUFFIX
96
+ with open(meta_path, "w", encoding="utf-8") as m:
97
+ json.dump({"user_at_host": user_at_host}, m)
98
+
91
99
  return file_path
100
+ # --- Core functionality -------------------------------------------------------
101
+ ##def write_to_file(*args, **kwargs):
102
+ ## """
103
+ ## Write contents to a file (create if missing).
104
+ ##
105
+ ## Returns the file_path written.
106
+ ## """
107
+ ## file_path, contents = check_read_write_params(*args, **kwargs)
108
+ ## if contents is None:
109
+ ## raise ValueError("Missing contents to write.")
110
+ ##
111
+ ## os.makedirs(os.path.dirname(file_path) or ".", exist_ok=True)
112
+ ## with open(file_path, "w", encoding="utf-8") as f:
113
+ ## f.write(str(contents))
114
+ ## return file_path
92
115
 
93
116
 
94
117
  def read_from_file(file_path,**kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstract_utilities
3
- Version: 0.2.2.455
3
+ Version: 0.2.2.456
4
4
  Summary: abstract_utilities is a collection of utility modules providing a variety of functions to aid in tasks such as data comparison, list manipulation, JSON handling, string manipulation, mathematical computations, and time operations.
5
5
  Home-page: https://github.com/AbstractEndeavors/abstract_utilities
6
6
  Author: putkoff
@@ -14,7 +14,7 @@ abstract_utilities/log_utils.py,sha256=W74Y-CmdQP4Kj88HmAgejVxWgyWlvgCKMwLvOfyFf
14
14
  abstract_utilities/math_utils.py,sha256=0o1ls1En03UAkYmxTBildCCJDfHygmNuvVnrNrLYtK0,6578
15
15
  abstract_utilities/parse_utils.py,sha256=Z5OGRwHuzCzY91fz0JJojk1BPAo1XF2quNNLuBF4_Vk,18602
16
16
  abstract_utilities/path_utils.py,sha256=X_U9cPBbNu5Wi0F3hQE0gXQX1gfhzxhxALbairTEOZU,19252
17
- abstract_utilities/read_write_utils.py,sha256=oPmY0UZSuEkV_ox8inZiSG_adYGm6J9n6-lgFNytdi0,4470
17
+ abstract_utilities/read_write_utils.py,sha256=OeOzohHVpGnXYyA50aV4W_Xj6qarvwMhN9xNEy8KhW0,5254
18
18
  abstract_utilities/safe_utils.py,sha256=_uoZny6dJjopVakOiaf0UIZcvRRXMh51FpfDUooe0xY,3733
19
19
  abstract_utilities/string_clean.py,sha256=-gY9i2yqjX5UClvSaKsSrzA4GjR7eaNI3GnFjZpt2bo,5923
20
20
  abstract_utilities/string_utils.py,sha256=02xdIEDySWEexrtY3skBYOdeDmr3XgE5j1nqAeAv7w8,352
@@ -78,7 +78,7 @@ abstract_utilities/ssh_utils/classes.py,sha256=3Q9BfLpyagNFYyiF4bt-5UCezeUJv9NK9
78
78
  abstract_utilities/ssh_utils/imports.py,sha256=oX8WAv-pkhizzko_h3fIUp9Vhsse4nR7RN2vwONxIx0,317
79
79
  abstract_utilities/ssh_utils/pexpect_utils.py,sha256=JBdOIXBTXAqE5TrsFjmPWJgwSaWyRJN8rbJ6y3_zKPY,10556
80
80
  abstract_utilities/ssh_utils/utils.py,sha256=smUWAx3nW1h0etTndJ_te9bkUX5YzQ8kYd9_gD1TXLk,4882
81
- abstract_utilities-0.2.2.455.dist-info/METADATA,sha256=tb1CM0tj1OQ-G_2tEiYK6CAasbWr6ELxn2hogEnEa8s,28108
82
- abstract_utilities-0.2.2.455.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
83
- abstract_utilities-0.2.2.455.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
84
- abstract_utilities-0.2.2.455.dist-info/RECORD,,
81
+ abstract_utilities-0.2.2.456.dist-info/METADATA,sha256=7xIkE91A13osv1AF4TpEe6an6XkbK0z2j8Sgo9ovrco,28108
82
+ abstract_utilities-0.2.2.456.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
83
+ abstract_utilities-0.2.2.456.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
84
+ abstract_utilities-0.2.2.456.dist-info/RECORD,,