abstract-utilities 0.2.2.490__py3-none-any.whl → 0.2.2.493__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.
@@ -14,10 +14,12 @@ Usage:
14
14
 
15
15
  import os
16
16
  import shlex
17
+ from .string_clean import *
17
18
  from .ssh_utils.utils import run_cmd,get_print_sudo_cmd,run_local_cmd,run_remote_cmd
18
19
  from .file_utils.file_utils.type_checks import is_file,is_dir,get_user_pass_host_key,is_exists
19
20
  from .abstract_classes import run_pruned_func
20
21
  from .string_utils import get_from_kwargs
22
+
21
23
  _FILE_PATH_KEYS = ['file', 'filepath', 'file_path', 'path', 'directory', 'f', 'dst', 'dest']
22
24
  _CONTENTS_KEYS = ['cont', 'content', 'contents', 'data', 'datas', 'dat', 'src', 'source']
23
25
 
@@ -248,27 +250,44 @@ def read_from_file(file_path,**kwargs):
248
250
  with open(file_path, "r", encoding="utf-8") as f:
249
251
  return f.read()
250
252
 
251
- def copy_dirs(dirs,dst,src_rel=None,**kwargs):
253
+
254
+ def copy_dirs(dirs, dst_root, src_rel=None, **kwargs):
255
+ """
256
+ Recursively copy directory structures (without files) from dirs → dst_root.
257
+ """
252
258
  for src in dirs:
253
- if rel_path:
254
- dst = make_relative_path(src,src_rel,dst,**kwargs)
255
- make_path(dst,**kwargs)
256
-
257
- def copy_file(src,dst,rel_path=None,**kwargs):
258
-
259
- if rel_path:
260
- dst = make_relative_path(src,rel_path,dst,**kwargs)
261
- print(dst)
262
- if get_user_pass_host_key(**kwargs):
263
- contents=read_from_file(src,**kwargs)
264
- write_to_file(contents=contents,file_path=dst,**kwargs)
265
- else:
266
- shutil.copy(src,dst)
267
- print(dst)
268
- return dst
269
- def copy_files(files,dst,rel_path=None,**kwargs):
270
- for file in files:
271
- copy_file(src=file,dst=dst,rel_path=rel_path,**kwargs)
259
+ # build destination path preserving relative structure
260
+ dst_path = make_relative_path(src, src_rel, dst_root, **kwargs) if src_rel else dst_root
261
+ make_path(dst_path, **kwargs) # ensures directory exists
262
+ print(f"✅ created directory: {dst_path}")
263
+
264
+
265
+ def copy_file(src, dst_root, src_rel=None, **kwargs):
266
+ """
267
+ Copy a single file to dst_root, preserving relative structure if src_rel provided.
268
+ Supports remote copy via read/write.
269
+ """
270
+ # derive destination file path
271
+ dst_path = make_relative_path(src, src_rel, dst_root, **kwargs) if src_rel else os.path.join(dst_root, os.path.basename(src))
272
+ make_path(dst_path, **kwargs)
273
+
274
+ if get_user_pass_host_key(**kwargs): # remote mode
275
+ contents = read_from_file(src, **kwargs)
276
+ write_to_file(contents=contents, file_path=dst_path, **kwargs)
277
+ else: # local
278
+ os.makedirs(os.path.dirname(dst_path), exist_ok=True)
279
+ shutil.copy2(src, dst_path)
280
+
281
+ print(f"📄 copied {src} → {dst_path}")
282
+ return dst_path
283
+
284
+
285
+ def copy_files(files, dst_root, src_rel=None, **kwargs):
286
+ """
287
+ Copy a list of files to dst_root.
288
+ """
289
+ for src in files:
290
+ copy_file(src=src, dst_root=dst_root, src_rel=src_rel, **kwargs)
272
291
 
273
292
  def create_and_read_file(*args, **kwargs):
274
293
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstract_utilities
3
- Version: 0.2.2.490
3
+ Version: 0.2.2.493
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=jcdMLBFrLRzkGRvEXS7PArh182Q2nVMIDn3Jf6sN27k,10139
17
+ abstract_utilities/read_write_utils.py,sha256=vhJ4E6LXruNyNtYs54j8r9UVYYl8TTkgnV2vScdSTmg,10897
18
18
  abstract_utilities/safe_utils.py,sha256=_uoZny6dJjopVakOiaf0UIZcvRRXMh51FpfDUooe0xY,3733
19
19
  abstract_utilities/string_clean.py,sha256=oQv85J-mA4sP2NJwbTI-1k0RXw7V0AmqZolYaAZvex4,6916
20
20
  abstract_utilities/string_utils.py,sha256=PnII0wFQBchVzFjhvEHP9ej1zxLehsRKodtc8Qol4-8,1645
@@ -86,7 +86,7 @@ abstract_utilities/ssh_utils/classes.py,sha256=3Q9BfLpyagNFYyiF4bt-5UCezeUJv9NK9
86
86
  abstract_utilities/ssh_utils/imports.py,sha256=oX8WAv-pkhizzko_h3fIUp9Vhsse4nR7RN2vwONxIx0,317
87
87
  abstract_utilities/ssh_utils/pexpect_utils.py,sha256=JBdOIXBTXAqE5TrsFjmPWJgwSaWyRJN8rbJ6y3_zKPY,10556
88
88
  abstract_utilities/ssh_utils/utils.py,sha256=smUWAx3nW1h0etTndJ_te9bkUX5YzQ8kYd9_gD1TXLk,4882
89
- abstract_utilities-0.2.2.490.dist-info/METADATA,sha256=WWRDaP8kZyQEUTeFvVxSfRwPk_Kj1s5JZ3jf-lqiUMM,28108
90
- abstract_utilities-0.2.2.490.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
- abstract_utilities-0.2.2.490.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
92
- abstract_utilities-0.2.2.490.dist-info/RECORD,,
89
+ abstract_utilities-0.2.2.493.dist-info/METADATA,sha256=5fonFmKwTqHgagaRcRtNHytPy7ZT9K2X9Cq03iWpjbw,28108
90
+ abstract_utilities-0.2.2.493.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ abstract_utilities-0.2.2.493.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
92
+ abstract_utilities-0.2.2.493.dist-info/RECORD,,