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

Files changed (190) hide show
  1. abstract_utilities/__init__.py +6 -10
  2. abstract_utilities/circular_import_finder.py +222 -0
  3. abstract_utilities/circular_import_finder2.py +118 -0
  4. abstract_utilities/class_utils/__init__.py +7 -0
  5. abstract_utilities/class_utils/abstract_classes.py +74 -0
  6. abstract_utilities/class_utils/caller_utils.py +35 -0
  7. abstract_utilities/class_utils/class_utils.py +109 -0
  8. abstract_utilities/class_utils/function_utils.py +153 -0
  9. abstract_utilities/class_utils/global_utils.py +56 -0
  10. abstract_utilities/class_utils/imports/__init__.py +2 -0
  11. abstract_utilities/class_utils/imports/imports.py +2 -0
  12. abstract_utilities/class_utils/imports/utils.py +40 -0
  13. abstract_utilities/class_utils/module_utils.py +63 -0
  14. abstract_utilities/directory_utils/__init__.py +2 -0
  15. abstract_utilities/directory_utils/directory_utils.py +94 -0
  16. abstract_utilities/directory_utils/imports/__init__.py +2 -0
  17. abstract_utilities/directory_utils/imports/imports.py +1 -0
  18. abstract_utilities/directory_utils/imports/module_imports.py +2 -0
  19. abstract_utilities/directory_utils/name_utils.py +43 -0
  20. abstract_utilities/directory_utils/size_utils.py +57 -0
  21. abstract_utilities/directory_utils/src/__init__.py +4 -0
  22. abstract_utilities/directory_utils/src/directory_utils.py +92 -0
  23. abstract_utilities/directory_utils/src/name_utils.py +43 -0
  24. abstract_utilities/directory_utils/src/size_utils.py +57 -0
  25. abstract_utilities/directory_utils/src/utils.py +116 -0
  26. abstract_utilities/directory_utils/utils.py +116 -0
  27. abstract_utilities/env_utils/imports/imports.py +5 -3
  28. abstract_utilities/error_utils/__init__.py +2 -0
  29. abstract_utilities/error_utils/error_utils.py +25 -0
  30. abstract_utilities/error_utils/imports/__init__.py +2 -0
  31. abstract_utilities/error_utils/imports/imports.py +1 -0
  32. abstract_utilities/error_utils/imports/module_imports.py +1 -0
  33. abstract_utilities/file_utils/__init__.py +1 -2
  34. abstract_utilities/file_utils/file_utils/imports/module_imports.py +2 -1
  35. abstract_utilities/file_utils/file_utils/type_checks.py +34 -24
  36. abstract_utilities/file_utils/imports/constants.py +84 -4
  37. abstract_utilities/file_utils/imports/imports.py +3 -18
  38. abstract_utilities/file_utils/imports/module_imports.py +2 -7
  39. abstract_utilities/file_utils/module_imports.py +12 -0
  40. abstract_utilities/file_utils/src/__init__.py +8 -0
  41. abstract_utilities/file_utils/src/file_filters.py +177 -0
  42. abstract_utilities/file_utils/src/file_reader.py +544 -0
  43. abstract_utilities/file_utils/src/file_utils.py +156 -0
  44. abstract_utilities/file_utils/src/filter_params.py +197 -0
  45. abstract_utilities/file_utils/src/find_collect.py +266 -0
  46. abstract_utilities/file_utils/src/initFunctionsGen.py +280 -0
  47. abstract_utilities/file_utils/src/map_utils.py +29 -0
  48. abstract_utilities/file_utils/src/pdf_utils.py +300 -0
  49. abstract_utilities/file_utils/src/type_checks.py +91 -0
  50. abstract_utilities/file_utils (2)/__init__.py +2 -0
  51. abstract_utilities/file_utils (2)/imports/__init__.py +2 -0
  52. abstract_utilities/file_utils (2)/imports/constants.py +118 -0
  53. abstract_utilities/file_utils (2)/imports/imports/__init__.py +3 -0
  54. abstract_utilities/file_utils (2)/imports/imports/constants.py +119 -0
  55. abstract_utilities/file_utils (2)/imports/imports/imports.py +46 -0
  56. abstract_utilities/file_utils (2)/imports/imports/module_imports.py +8 -0
  57. abstract_utilities/file_utils (2)/imports/utils/__init__.py +3 -0
  58. abstract_utilities/file_utils (2)/imports/utils/classes.py +379 -0
  59. abstract_utilities/file_utils (2)/imports/utils/clean_imps.py +155 -0
  60. abstract_utilities/file_utils (2)/imports/utils/filter_utils.py +341 -0
  61. abstract_utilities/file_utils (2)/src/__init__.py +8 -0
  62. abstract_utilities/file_utils (2)/src/file_filters.py +155 -0
  63. abstract_utilities/file_utils (2)/src/file_reader.py +604 -0
  64. abstract_utilities/file_utils (2)/src/find_collect.py +258 -0
  65. abstract_utilities/file_utils (2)/src/initFunctionsGen.py +286 -0
  66. abstract_utilities/file_utils (2)/src/map_utils.py +28 -0
  67. abstract_utilities/file_utils (2)/src/pdf_utils.py +300 -0
  68. abstract_utilities/hash_utils/__init__.py +2 -0
  69. abstract_utilities/hash_utils/hash_utils.py +5 -0
  70. abstract_utilities/hash_utils/imports/__init__.py +2 -0
  71. abstract_utilities/hash_utils/imports/imports.py +1 -0
  72. abstract_utilities/hash_utils/imports/module_imports.py +0 -0
  73. abstract_utilities/history_utils/__init__.py +2 -0
  74. abstract_utilities/history_utils/history_utils.py +37 -0
  75. abstract_utilities/history_utils/imports/__init__.py +2 -0
  76. abstract_utilities/history_utils/imports/imports.py +1 -0
  77. abstract_utilities/history_utils/imports/module_imports.py +0 -0
  78. abstract_utilities/import_utils/__init__.py +2 -0
  79. abstract_utilities/import_utils/imports/__init__.py +4 -0
  80. abstract_utilities/import_utils/imports/constants.py +2 -0
  81. abstract_utilities/import_utils/imports/imports.py +4 -0
  82. abstract_utilities/import_utils/imports/module_imports.py +6 -0
  83. abstract_utilities/import_utils/imports/utils.py +30 -0
  84. abstract_utilities/import_utils/src/__init__.py +7 -0
  85. abstract_utilities/import_utils/src/clean_imports.py +147 -0
  86. abstract_utilities/import_utils/src/dot_utils.py +69 -0
  87. abstract_utilities/import_utils/src/extract_utils.py +42 -0
  88. abstract_utilities/import_utils/src/import_functions.py +46 -0
  89. abstract_utilities/import_utils/src/import_utils.py +299 -0
  90. abstract_utilities/import_utils/src/package_utils/__init__.py +139 -0
  91. abstract_utilities/import_utils/src/package_utils/context_utils.py +27 -0
  92. abstract_utilities/import_utils/src/package_utils/import_collectors.py +53 -0
  93. abstract_utilities/import_utils/src/package_utils/path_utils.py +28 -0
  94. abstract_utilities/import_utils/src/package_utils/safe_import.py +27 -0
  95. abstract_utilities/import_utils/src/package_utils.py +140 -0
  96. abstract_utilities/import_utils/src/package_utilss/__init__.py +139 -0
  97. abstract_utilities/import_utils/src/package_utilss/context_utils.py +27 -0
  98. abstract_utilities/import_utils/src/package_utilss/import_collectors.py +53 -0
  99. abstract_utilities/import_utils/src/package_utilss/path_utils.py +28 -0
  100. abstract_utilities/import_utils/src/package_utilss/safe_import.py +27 -0
  101. abstract_utilities/import_utils/src/pkg_utils.py +140 -0
  102. abstract_utilities/import_utils/src/sysroot_utils.py +57 -0
  103. abstract_utilities/imports.py +18 -0
  104. abstract_utilities/json_utils/__init__.py +2 -0
  105. abstract_utilities/json_utils/imports/__init__.py +2 -0
  106. abstract_utilities/json_utils/imports/imports.py +2 -0
  107. abstract_utilities/json_utils/imports/module_imports.py +5 -0
  108. abstract_utilities/json_utils/json_utils.py +743 -0
  109. abstract_utilities/list_utils/__init__.py +2 -0
  110. abstract_utilities/list_utils/imports/__init__.py +2 -0
  111. abstract_utilities/list_utils/imports/imports.py +1 -0
  112. abstract_utilities/list_utils/imports/module_imports.py +0 -0
  113. abstract_utilities/list_utils/list_utils.py +199 -0
  114. abstract_utilities/log_utils/__init__.py +5 -0
  115. abstract_utilities/log_utils/abstractLogManager.py +64 -0
  116. abstract_utilities/log_utils/call_response.py +68 -0
  117. abstract_utilities/log_utils/imports/__init__.py +2 -0
  118. abstract_utilities/log_utils/imports/imports.py +7 -0
  119. abstract_utilities/log_utils/imports/module_imports.py +2 -0
  120. abstract_utilities/log_utils/log_file.py +58 -0
  121. abstract_utilities/log_utils/logger_callable.py +49 -0
  122. abstract_utilities/math_utils/__init__.py +2 -0
  123. abstract_utilities/math_utils/imports/__init__.py +2 -0
  124. abstract_utilities/math_utils/imports/imports.py +2 -0
  125. abstract_utilities/math_utils/imports/module_imports.py +1 -0
  126. abstract_utilities/math_utils/math_utils.py +208 -0
  127. abstract_utilities/parse_utils/__init__.py +2 -0
  128. abstract_utilities/parse_utils/imports/__init__.py +3 -0
  129. abstract_utilities/parse_utils/imports/constants.py +10 -0
  130. abstract_utilities/parse_utils/imports/imports.py +2 -0
  131. abstract_utilities/parse_utils/imports/module_imports.py +4 -0
  132. abstract_utilities/parse_utils/parse_utils.py +516 -0
  133. abstract_utilities/path_utils/__init__.py +2 -0
  134. abstract_utilities/path_utils/imports/__init__.py +3 -0
  135. abstract_utilities/path_utils/imports/imports.py +1 -0
  136. abstract_utilities/path_utils/imports/module_imports.py +8 -0
  137. abstract_utilities/path_utils/path_utils.py +251 -0
  138. abstract_utilities/path_utils.py +95 -14
  139. abstract_utilities/read_write_utils/__init__.py +1 -0
  140. abstract_utilities/read_write_utils/imports/__init__.py +2 -0
  141. abstract_utilities/read_write_utils/imports/imports.py +2 -0
  142. abstract_utilities/read_write_utils/imports/module_imports.py +5 -0
  143. abstract_utilities/read_write_utils/read_write_utils.py +338 -0
  144. abstract_utilities/read_write_utils.py +142 -20
  145. abstract_utilities/safe_utils/__init__.py +2 -0
  146. abstract_utilities/safe_utils/imports/__init__.py +3 -0
  147. abstract_utilities/safe_utils/imports/imports.py +2 -0
  148. abstract_utilities/safe_utils/imports/module_imports.py +2 -0
  149. abstract_utilities/safe_utils/safe_utils.py +136 -0
  150. abstract_utilities/ssh_utils/__init__.py +3 -1
  151. abstract_utilities/ssh_utils/classes.py +0 -1
  152. abstract_utilities/ssh_utils/cmd_utils.py +207 -0
  153. abstract_utilities/ssh_utils/imports/__init__.py +3 -0
  154. abstract_utilities/ssh_utils/imports/imports.py +5 -0
  155. abstract_utilities/ssh_utils/imports/module_imports.py +6 -0
  156. abstract_utilities/ssh_utils/imports/utils.py +189 -0
  157. abstract_utilities/ssh_utils/pexpect_utils.py +11 -18
  158. abstract_utilities/ssh_utils/type_checks.py +92 -0
  159. abstract_utilities/string_utils/__init__.py +4 -0
  160. abstract_utilities/string_utils/clean_utils.py +28 -0
  161. abstract_utilities/string_utils/eat_utils.py +103 -0
  162. abstract_utilities/string_utils/imports/__init__.py +3 -0
  163. abstract_utilities/string_utils/imports/imports.py +2 -0
  164. abstract_utilities/string_utils/imports/module_imports.py +2 -0
  165. abstract_utilities/string_utils/imports/utils.py +81 -0
  166. abstract_utilities/string_utils/replace_utils.py +27 -0
  167. abstract_utilities/string_utils.py +4 -1
  168. abstract_utilities/thread_utils/__init__.py +2 -0
  169. abstract_utilities/thread_utils/imports/__init__.py +2 -0
  170. abstract_utilities/thread_utils/imports/imports.py +2 -0
  171. abstract_utilities/thread_utils/imports/module_imports.py +2 -0
  172. abstract_utilities/thread_utils/thread_utils.py +140 -0
  173. abstract_utilities/time_utils/__init__.py +2 -0
  174. abstract_utilities/time_utils/imports/__init__.py +2 -0
  175. abstract_utilities/time_utils/imports/imports.py +3 -0
  176. abstract_utilities/time_utils/imports/module_imports.py +1 -0
  177. abstract_utilities/time_utils/time_utils.py +392 -0
  178. abstract_utilities/type_utils/__init__.py +3 -0
  179. abstract_utilities/type_utils/alpha_utils.py +59 -0
  180. abstract_utilities/type_utils/imports/__init__.py +2 -0
  181. abstract_utilities/type_utils/imports/imports.py +4 -0
  182. abstract_utilities/type_utils/imports/module_imports.py +1 -0
  183. abstract_utilities/type_utils/num_utils.py +19 -0
  184. abstract_utilities/type_utils/type_utils.py +981 -0
  185. {abstract_utilities-0.2.2.476.dist-info → abstract_utilities-0.2.2.540.dist-info}/METADATA +1 -1
  186. abstract_utilities-0.2.2.540.dist-info/RECORD +263 -0
  187. imports/__init__.py +36 -0
  188. abstract_utilities-0.2.2.476.dist-info/RECORD +0 -92
  189. {abstract_utilities-0.2.2.476.dist-info → abstract_utilities-0.2.2.540.dist-info}/WHEEL +0 -0
  190. {abstract_utilities-0.2.2.476.dist-info → abstract_utilities-0.2.2.540.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,57 @@
1
+ from ..imports import *
2
+ from .name_utils import *
3
+ def get_os_info():
4
+ """
5
+ Get Operating System Information
6
+
7
+ This function retrieves information about the current operating system, including its name and bit size.
8
+
9
+ Returns:
10
+ - os_info (dict): A dictionary containing the operating system information.
11
+ Keys:
12
+ - "operating_system" (str): The name of the operating system (e.g., "Windows", "Linux", "Darwin").
13
+ - "bit_size" (str): The bit size of the operating system (e.g., "32bit", "64bit").
14
+
15
+ Example:
16
+ os_info = get_os_info()
17
+ print("Operating System:", os_info["operating_system"])
18
+ print("Bit Size:", os_info["bit_size"])
19
+ """
20
+ os_name = platform.system()
21
+ bit_size = platform.architecture()[0]
22
+ return {"operating_system": os_name, "bit_size": bit_size}
23
+ def mkGb(k) -> float:
24
+ """
25
+ Converts a value to Gigabytes (GB).
26
+
27
+ Args:
28
+ k (float): The value to convert to GB.
29
+
30
+ Returns:
31
+ float: The value converted to GB.
32
+ """
33
+ return float(float(k)*(10**9))
34
+
35
+ def mkGbTrunk(k) -> float:
36
+ """
37
+ Converts a value to Gigabytes (GB) and truncates the result to five decimal places.
38
+
39
+ Args:
40
+ k (float): The value to convert to GB.
41
+
42
+ Returns:
43
+ float: The value converted to GB and truncated to five decimal places.
44
+ """
45
+ return trunc(mkGb(k), 5)
46
+
47
+ def mkGbTrunFroPathTot(k) -> float:
48
+ """
49
+ Fetches the file size from a path, converts it to Gigabytes (GB) and truncates the result to five decimal places.
50
+
51
+ Args:
52
+ k (str): The file path.
53
+
54
+ Returns:
55
+ float: The file size converted to GB and truncated to five decimal places.
56
+ """
57
+ return trunc(mkGb(s.path.getsize(k)), 5)
@@ -0,0 +1,116 @@
1
+ from ..imports import *
2
+ def split_text(string: str) -> tuple:
3
+ """
4
+ Splits a string into its base name and extension and returns them as a tuple.
5
+
6
+ Args:
7
+ string (str): A string to be split, typically representing a file name.
8
+
9
+ Returns:
10
+ tuple: A tuple containing the base name and extension of the input string.
11
+ """
12
+ return os.path.splitext(string)
13
+ def get_ext(file_path: str) -> str:
14
+ """
15
+ Retrieves and returns the extension of a file from a given file path.
16
+
17
+ Args:
18
+ file_path (str): A string representing the file path.
19
+
20
+ Returns:
21
+ str: The extension of the file (including the dot).
22
+ """
23
+ return split_text(get_base_name(file_path))[1]
24
+
25
+ def get_slash():
26
+ """
27
+ Returns the appropriate file path separator depending on the current operating system.
28
+ """
29
+ slash = '/' # Assume a Unix-like system by default
30
+ if slash not in get_current_path():
31
+ slash = '\\' # Use backslash for Windows systems
32
+ return slash
33
+ def get_current_path():
34
+ """
35
+ Returns the current working directory.
36
+
37
+ Returns:
38
+ str: The current working directory.
39
+ """
40
+ return os.getcwd()
41
+
42
+ def get_home_folder():
43
+ """
44
+ Returns the path to the home directory of the current user.
45
+
46
+ Returns:
47
+ str: The path to the home directory.
48
+ """
49
+ return os.path.expanduser("~")
50
+ def simple_path_join(path_A:str, path_B:str):
51
+ """
52
+ Join two paths using the appropriate file path separator.
53
+
54
+ Args:
55
+ path_A (str): The first path to join.
56
+ path_B (str): The second path to join.
57
+
58
+ Returns:
59
+ str: The joined path.
60
+ """
61
+ return os.path.join(str(path_A), str(path_B))
62
+
63
+ def path_join(path_A, path_B=None):
64
+ """
65
+ Joins two paths or a list of paths using the appropriate file path separator.
66
+
67
+ Args:
68
+ path_A (str or list): The first path or list of paths to join.
69
+ path_B (str, optional): The second path to join. Defaults to None.
70
+
71
+ Returns:
72
+ str: The joined path.
73
+ """
74
+ if path_B is not None: # If path_B is provided, join path_A and path_B
75
+ return simple_path_join(path_A, path_B)
76
+ if isinstance(path_A, list): # If path_A is a list, join all paths in the list
77
+ path = path_A[0]
78
+ for k in range(1, len(path_A)):
79
+ path = simple_path_join(path, path_A[k])
80
+ return path
81
+ def update_global_variable(name: str, value) -> None:
82
+ """Updates the global variable with the provided name and value.
83
+
84
+ Args:
85
+ name (str): The name of the global variable.
86
+ value: The value to assign to the global variable.
87
+
88
+ Returns:
89
+ None
90
+ """
91
+ globals()[name] = value
92
+
93
+
94
+ def trunc(a: float, x: int) -> float:
95
+ """
96
+ Truncates a float number to a specific number of decimal places.
97
+
98
+ Args:
99
+ a (float): The number to truncate.
100
+ x (int): The number of decimal places to retain.
101
+
102
+ Returns:
103
+ float: The truncated float number.
104
+ """
105
+ temp = str(a)
106
+ for i in range(len(temp)):
107
+ if temp[i] == '.':
108
+ try:
109
+ return float(temp[:i+x+1])
110
+ except:
111
+ return float(temp)
112
+ return float(temp)
113
+
114
+
115
+
116
+
@@ -0,0 +1,116 @@
1
+ from ..imports import *
2
+ def split_text(string: str) -> tuple:
3
+ """
4
+ Splits a string into its base name and extension and returns them as a tuple.
5
+
6
+ Args:
7
+ string (str): A string to be split, typically representing a file name.
8
+
9
+ Returns:
10
+ tuple: A tuple containing the base name and extension of the input string.
11
+ """
12
+ return os.path.splitext(string)
13
+ def get_ext(file_path: str) -> str:
14
+ """
15
+ Retrieves and returns the extension of a file from a given file path.
16
+
17
+ Args:
18
+ file_path (str): A string representing the file path.
19
+
20
+ Returns:
21
+ str: The extension of the file (including the dot).
22
+ """
23
+ return split_text(get_base_name(file_path))[1]
24
+
25
+ def get_slash():
26
+ """
27
+ Returns the appropriate file path separator depending on the current operating system.
28
+ """
29
+ slash = '/' # Assume a Unix-like system by default
30
+ if slash not in get_current_path():
31
+ slash = '\\' # Use backslash for Windows systems
32
+ return slash
33
+ def get_current_path():
34
+ """
35
+ Returns the current working directory.
36
+
37
+ Returns:
38
+ str: The current working directory.
39
+ """
40
+ return os.getcwd()
41
+
42
+ def get_home_folder():
43
+ """
44
+ Returns the path to the home directory of the current user.
45
+
46
+ Returns:
47
+ str: The path to the home directory.
48
+ """
49
+ return os.path.expanduser("~")
50
+ def simple_path_join(path_A:str, path_B:str):
51
+ """
52
+ Join two paths using the appropriate file path separator.
53
+
54
+ Args:
55
+ path_A (str): The first path to join.
56
+ path_B (str): The second path to join.
57
+
58
+ Returns:
59
+ str: The joined path.
60
+ """
61
+ return os.path.join(str(path_A), str(path_B))
62
+
63
+ def path_join(path_A, path_B=None):
64
+ """
65
+ Joins two paths or a list of paths using the appropriate file path separator.
66
+
67
+ Args:
68
+ path_A (str or list): The first path or list of paths to join.
69
+ path_B (str, optional): The second path to join. Defaults to None.
70
+
71
+ Returns:
72
+ str: The joined path.
73
+ """
74
+ if path_B is not None: # If path_B is provided, join path_A and path_B
75
+ return simple_path_join(path_A, path_B)
76
+ if isinstance(path_A, list): # If path_A is a list, join all paths in the list
77
+ path = path_A[0]
78
+ for k in range(1, len(path_A)):
79
+ path = simple_path_join(path, path_A[k])
80
+ return path
81
+ def update_global_variable(name: str, value) -> None:
82
+ """Updates the global variable with the provided name and value.
83
+
84
+ Args:
85
+ name (str): The name of the global variable.
86
+ value: The value to assign to the global variable.
87
+
88
+ Returns:
89
+ None
90
+ """
91
+ globals()[name] = value
92
+
93
+
94
+ def trunc(a: float, x: int) -> float:
95
+ """
96
+ Truncates a float number to a specific number of decimal places.
97
+
98
+ Args:
99
+ a (float): The number to truncate.
100
+ x (int): The number of decimal places to retain.
101
+
102
+ Returns:
103
+ float: The truncated float number.
104
+ """
105
+ temp = str(a)
106
+ for i in range(len(temp)):
107
+ if temp[i] == '.':
108
+ try:
109
+ return float(temp[:i+x+1])
110
+ except:
111
+ return float(temp)
112
+ return float(temp)
113
+
114
+
115
+
116
+
@@ -1,8 +1,10 @@
1
- import os
1
+ from ...imports import os
2
2
  from dotenv import load_dotenv
3
- from ...string_clean import eatAll,eatInner,eatOuter,safe_split
3
+ from ...ssh_utils import is_file
4
+ from ...string_utils import eatAll,eatInner,eatOuter
5
+ from ...safe_utils import safe_split
4
6
  from ...compare_utils import line_contains
5
7
  from ...type_utils import is_list,is_bool
6
- from ...path_utils import get_slash,path_join,if_not_last_child_join,get_home_folder,simple_path_join,is_file
8
+ from ...directory_utils import get_slash,path_join,if_not_last_child_join,get_home_folder,simple_path_join
7
9
  DEFAULT_FILE_NAME = '.env'
8
10
  DEFAULT_KEY = 'MY_PASSWORD'
@@ -0,0 +1,2 @@
1
+ from .imports import *
2
+ from .error_utils import *
@@ -0,0 +1,25 @@
1
+ from .imports import *
2
+ def try_func(func, *args, logger=None, level='error', **kwargs):
3
+ """
4
+ Execute a function with try-except and log exceptions.
5
+
6
+ Args:
7
+ func: Function to execute.
8
+ *args: Positional arguments for the function.
9
+ logger: Logger object, logger method (e.g., logger.error), or None.
10
+ level (str): Logging level for exceptions (e.g., 'error').
11
+ **kwargs: Keyword arguments for the function.
12
+
13
+ Returns:
14
+ Result of the function if successful.
15
+
16
+ Raises:
17
+ Exception: If the function fails and logger is used to log the error.
18
+ """
19
+ log_callable = get_logger_callable(logger=logger, level=level)
20
+ try:
21
+ return func(*args, **kwargs)
22
+ except Exception as e:
23
+ if log_callable:
24
+ log_callable(f"Exception in {func.__name__}: {str(e)}")
25
+ raise
@@ -0,0 +1,2 @@
1
+ from .imports import *
2
+ from .module_imports import *
@@ -0,0 +1 @@
1
+ from ...log_utils import get_logger_callable
@@ -1,3 +1,2 @@
1
1
  from .imports import *
2
- from .file_utils import *
3
- from .req import call_for_all_tabs,get_for_all_tabs
2
+ from .src import *
@@ -6,7 +6,8 @@ from ....ssh_utils import *
6
6
  from ....env_utils import *
7
7
  from ....read_write_utils import *
8
8
  from ....abstract_classes import SingletonMeta
9
-
9
+ from ....string_utils import get_from_kwargs
10
+ from ....abstract_classes import run_pruned_func
10
11
  from ....class_utils import get_caller, get_caller_path, get_caller_dir
11
12
 
12
13
 
@@ -1,34 +1,37 @@
1
1
  from .imports import *
2
2
 
3
+ def get_user_pass_host_key(**kwargs):
4
+ args = ['password','user_at_host','host','key','user']
5
+ kwargs['del_kwarg']=kwargs.get('del_kwarg',False)
6
+ values,kwargs = get_from_kwargs(*args,**kwargs)
7
+ return values
3
8
 
4
9
  # --- Base remote checker -----------------------------------------------------
5
- def _remote_test(path: str, test_flag: str, user_at_host: str, timeout: int = 5) -> bool:
10
+ def _remote_test(path: str, test_flag: str, timeout: int = 5,*args, **kwargs) -> bool:
6
11
  """
7
12
  Run a remote shell test (e.g. -f, -d) via SSH.
8
13
  Returns True if test succeeds, False otherwise.
9
14
  """
10
- cmd = f"[ {test_flag} {shlex.quote(path)} ] && echo 1 || echo 0"
11
15
  try:
12
- result = subprocess.check_output(
13
- ["ssh", user_at_host, cmd],
14
- stderr=subprocess.DEVNULL,
15
- text=True,
16
- timeout=timeout
17
- ).strip()
18
- return result == "1"
16
+ kwargs['cmd']=f"[ {test_flag} {shlex.quote(path)} ] && echo 1 || echo 0"
17
+ kwargs['text']=True
18
+ kwargs['timeout']=timeout
19
+ kwargs['stderr']=subprocess.DEVNULL
20
+ result = run_pruned_func(run_cmd,**kwargs)
21
+ return result.strip() == "1"
19
22
  except Exception:
20
23
  return False
21
24
 
22
25
 
23
26
  # --- Individual path checks --------------------------------------------------
24
- def is_remote_file(path: str, user_at_host: str) -> bool:
27
+ def is_remote_file(path: str,*args, **kwargs) -> bool:
25
28
  """True if remote path is a file."""
26
- return _remote_test(path, "-f", user_at_host)
29
+ return _remote_test(path, "-f", **kwargs)
27
30
 
28
31
 
29
- def is_remote_dir(path: str, user_at_host: str) -> bool:
32
+ def is_remote_dir(path: str,*args, **kwargs) -> bool:
30
33
  """True if remote path is a directory."""
31
- return _remote_test(path, "-d", user_at_host)
34
+ return _remote_test(path, "-d", **kwargs)
32
35
 
33
36
 
34
37
  def is_local_file(path: str) -> bool:
@@ -42,33 +45,40 @@ def is_local_dir(path: str) -> bool:
42
45
 
43
46
 
44
47
  # --- Unified interface -------------------------------------------------------
45
- def is_file(path: str,*args, user_at_host: Optional[str] = None,**kwargs) -> bool:
48
+
49
+ def is_file(path: str,*args,**kwargs) -> bool:
46
50
  """Determine if path is a file (works local or remote)."""
47
- if user_at_host:
48
- return is_remote_file(path, user_at_host)
51
+ if get_user_pass_host_key(**kwargs):
52
+ return is_remote_file(path, **kwargs)
49
53
  return is_local_file(path)
50
54
 
51
55
 
52
- def is_dir(path: str, *args,user_at_host: Optional[str] = None,**kwargs) -> bool:
56
+ def is_dir(path: str, *args,**kwargs) -> bool:
53
57
  """Determine if path is a directory (works local or remote)."""
54
- if user_at_host:
55
- return is_remote_dir(path, user_at_host)
58
+ if get_user_pass_host_key(**kwargs):
59
+ return is_remote_dir(path, **kwargs)
56
60
  return is_local_dir(path)
57
61
 
58
-
62
+ def is_exists(path: str, *args,**kwargs) -> bool:
63
+ if is_file(path,**kwargs):
64
+ return True
65
+ if is_dir(path,**kwargs):
66
+ return True
67
+ return False
59
68
  # --- Optional: keep your original all-in-one wrapper ------------------------
60
69
  def check_path_type(
61
70
  path: str,
62
- user_at_host: Optional[str] = None,
71
+ *args,
72
+ **kwargs
63
73
  ) -> str:
64
74
  """
65
75
  Return 'file', 'directory', 'missing', or 'unknown'.
66
76
  Uses isolated is_file/is_dir functions.
67
77
  """
68
- if user_at_host:
69
- if is_remote_file(path, user_at_host):
78
+ if get_user_pass_host_key(**kwargs):
79
+ if is_remote_file(path,**kwargs):
70
80
  return "file"
71
- elif is_remote_dir(path, user_at_host):
81
+ elif is_remote_dir(path,**kwargs):
72
82
  return "directory"
73
83
  else:
74
84
  return "missing"
@@ -1,12 +1,40 @@
1
1
  from .imports import *
2
2
  from .module_imports import *
3
+ # -------------------------
4
+ # Config dataclass
5
+ # -------------------------
6
+
3
7
  @dataclass
4
8
  class ScanConfig:
5
9
  allowed_exts: Set[str]
6
- unallowed_exts: Set[str]
10
+ exclude_exts: Set[str]
11
+ allowed_types: Set[str]
7
12
  exclude_types: Set[str]
13
+ allowed_dirs: List[str] = field(default_factory=list)
8
14
  exclude_dirs: List[str] = field(default_factory=list)
15
+ allowed_patterns: List[str] = field(default_factory=list)
9
16
  exclude_patterns: List[str] = field(default_factory=list)
17
+
18
+ @dataclass
19
+ class SearchParams(ScanConfig):
20
+ directories: List[str] = field(default_factory=list)
21
+ add: bool = False
22
+ recursive: bool = True
23
+ strings: List[str] = field(default_factory=list)
24
+ total_strings: bool = False
25
+ parse_lines: bool = False
26
+ spec_line: Union[bool, int] = False
27
+ get_lines: bool = False
28
+
29
+ @dataclass
30
+ class AllParams(SearchParams):
31
+ cfg = None
32
+ allowed: Optional[Callable[[str], bool]] = None
33
+ include_files: bool = True
34
+ recursive: bool = True
35
+ # -------------------------
36
+ # Default sets
37
+ # -------------------------
10
38
  DEFAULT_ALLOWED_EXTS: Set[str] = {
11
39
  ".py", ".pyw", # python
12
40
  ".js", ".jsx", ".ts", ".tsx", ".mjs", # JS/TS
@@ -24,11 +52,15 @@ DEFAULT_EXCLUDE_TYPES: Set[str] = {
24
52
  }
25
53
 
26
54
  # never want these—even if they sneak into ALLOWED
27
- _unallowed = set(get_media_exts(DEFAULT_EXCLUDE_TYPES)) | {'.bak', '.shp', '.cpg', '.dbf', '.shx','.geojson',".pyc",'.shx','.geojson','.prj','.sbn','.sbx'}
28
- DEFAULT_UNALLOWED_EXTS = {e for e in _unallowed if e not in DEFAULT_ALLOWED_EXTS}
55
+ _unallowed = set(get_media_exts(DEFAULT_EXCLUDE_TYPES)) | {
56
+ ".bak", ".shp", ".cpg", ".dbf", ".shx", ".geojson",
57
+ ".pyc", ".prj", ".sbn", ".sbx"
58
+ }
59
+ DEFAULT_EXCLUDE_EXTS = {e.split('.')[-1] for e in _unallowed if e not in DEFAULT_ALLOWED_EXTS}
29
60
 
30
61
  DEFAULT_EXCLUDE_DIRS: Set[str] = {
31
- "node_modules", "old","__pycache__", "backups", "backup", "backs", "trash", "depriciated", "old", "__init__"
62
+ "node_modules", "old","__pycache__", "backups", "backup",
63
+ "backs", "trash", "depriciated", "old", "__init__"
32
64
  }
33
65
 
34
66
  DEFAULT_EXCLUDE_PATTERNS: Set[str] = {
@@ -37,3 +69,51 @@ DEFAULT_EXCLUDE_PATTERNS: Set[str] = {
37
69
  REMOTE_RE = re.compile(r"^(?P<host>[^:\s]+@[^:\s]+):(?P<path>/.*)$")
38
70
  AllowedPredicate = Optional[Callable[[str], bool]]
39
71
  DEFAULT_EXCLUDE_FILE_PATTERNS=DEFAULT_EXCLUDE_PATTERNS
72
+ DEFAULT_ALLOWED_PATTERNS: List[str] = ["*"]
73
+ DEFAULT_ALLOWED_DIRS: List[str] = ["*"]
74
+ DEFAULT_ALLOWED_TYPES: List[str] = ["*"]
75
+ CANONICAL_MAP = {
76
+ "directories": ["directory", "directories", "dir","dirs","directory","directories","d","dirname", "paths", "path","roots","root"],
77
+ "files":["file","filepath","file_path","files","filepaths","file_paths","paths", "path","f"],
78
+ "allowed_exts": ["allow_ext", "allowed_ext", "include_ext", "include_exts", "exts_allowed"],
79
+ "exclude_exts": ["exclude_ext", "excluded_ext", "excluded_exts", "unallowed_ext", "unallowed_exts"],
80
+ "allowed_types": ["allow_type", "allowed_type", "include_type", "include_types", "types_allowed"],
81
+ "exclude_types": ["exclude_type", "excluded_type", "excluded_types", "unallowed_type", "unallowed_types"],
82
+ "allowed_dirs": ["allow_dir", "allowed_dir", "include_dir", "include_dirs", "dirs_allowed"],
83
+ "exclude_dirs": ["exclude_dir", "excluded_dir", "excluded_dirs", "unallowed_dir", "unallowed_dirs"],
84
+ "allowed_patterns": ["allow_pattern", "allowed_pattern", "include_pattern", "include_patterns", "patterns_allowed"],
85
+ "exclude_patterns": ["exclude_pattern", "excluded_pattern", "excluded_patterns", "unallowed_pattern", "unallowed_patterns"],
86
+ "add":["add"],
87
+ "cfg":["cfg"],
88
+ "recursive":["recursive"],
89
+ "strings":["strings"],
90
+ "total_strings":["total_strings"],
91
+ "parse_lines":["parse_lines"],
92
+ "spec_line":["spec_line"],
93
+ "get_lines":["get_lines"]
94
+ }
95
+ DEFAULT_ALLOWED_EXCLUDE_MAP={
96
+ "allowed_exts": {"default":DEFAULT_ALLOWED_EXTS,"type":type(DEFAULT_ALLOWED_EXTS),"canonical":CANONICAL_MAP.get("allowed_exts")},
97
+ "exclude_exts": {"default":DEFAULT_EXCLUDE_EXTS,"type":type(DEFAULT_EXCLUDE_EXTS),"canonical":CANONICAL_MAP.get("exclude_exts")},
98
+ "allowed_types": {"default":DEFAULT_ALLOWED_TYPES,"type":type(DEFAULT_ALLOWED_TYPES),"canonical":CANONICAL_MAP.get("allowed_types")},
99
+ "exclude_types": {"default":DEFAULT_EXCLUDE_TYPES,"type":type(DEFAULT_EXCLUDE_TYPES),"canonical":CANONICAL_MAP.get("exclude_types")},
100
+ "allowed_dirs": {"default":DEFAULT_ALLOWED_DIRS,"type":type(DEFAULT_ALLOWED_DIRS),"canonical":CANONICAL_MAP.get("allowed_dirs")},
101
+ "exclude_dirs": {"default":DEFAULT_EXCLUDE_DIRS,"type":type(DEFAULT_EXCLUDE_DIRS),"canonical":CANONICAL_MAP.get("exclude_dirs")},
102
+ "allowed_patterns": {"default":DEFAULT_ALLOWED_PATTERNS,"type":type(DEFAULT_ALLOWED_PATTERNS),"canonical":CANONICAL_MAP.get("allowed_patterns")},
103
+ "exclude_patterns": {"default":DEFAULT_EXCLUDE_PATTERNS,"type":type(DEFAULT_EXCLUDE_PATTERNS),"canonical":CANONICAL_MAP.get("exclude_patterns")},
104
+ }
105
+ DEFAULT_CANONICAL_MAP={
106
+ "directories":{"default":[],"type":list,"canonical":CANONICAL_MAP.get("directories")},
107
+ "files":{"default":[],"type":list,"canonical":CANONICAL_MAP.get("files")},
108
+ **DEFAULT_ALLOWED_EXCLUDE_MAP,
109
+ "allowed":{"default":None,"type":bool,"canonical":CANONICAL_MAP.get("allowed")},
110
+ "add":{"default":False,"type":bool,"canonical":CANONICAL_MAP.get("add")},
111
+ "recursive":{"default":True,"type":bool,"canonical":CANONICAL_MAP.get("recursive")},
112
+ "strings":{"default":None,"type":list,"canonical":CANONICAL_MAP.get("strings")},
113
+ "total_strings":{"default":False,"type":bool,"canonical":CANONICAL_MAP.get("total_strings")},
114
+ "parse_lines":{"default":False,"type":bool,"canonical":CANONICAL_MAP.get("parse_lines")},
115
+ "spec_line":{"default":False,"type":bool,"canonical":CANONICAL_MAP.get("spec_line")},
116
+ "get_lines":{"default":False,"type":bool,"canonical":CANONICAL_MAP.get("get_lines")},
117
+ }
118
+
119
+
@@ -6,23 +6,17 @@
6
6
  # ============================================================
7
7
 
8
8
 
9
- import os
10
- import sys, importlib,os
11
- import sys, importlib, os, inspect
9
+ from ...imports import *
12
10
  from pathlib import Path
13
- import os,sys
11
+
14
12
 
15
13
 
16
14
 
17
15
  from typing import *
18
- import re
19
16
 
20
17
  from typing import *
21
18
  from types import MethodType
22
- import os,re, sys, importlib, inspect, os, importlib.util, hashlib
23
- import os,tempfile,shutil,logging,ezodf,fnmatch,pytesseract,pdfplumber
24
- import pandas as pd
25
- import geopandas as gpd
19
+
26
20
  from datetime import datetime
27
21
 
28
22
  from typing import *
@@ -30,8 +24,6 @@ from werkzeug.utils import secure_filename
30
24
  from werkzeug.datastructures import FileStorage
31
25
  from pdf2image import convert_from_path # only used for OCR fallback
32
26
  # ---- Core standard library modules -------------------------
33
- import os, sys, re, shlex, glob, platform, textwrap, subprocess, inspect, json, time
34
- import tempfile, shutil, logging, pathlib, fnmatch, importlib, importlib.util, types
35
27
 
36
28
  from datetime import datetime
37
29
  from types import ModuleType
@@ -44,18 +36,11 @@ from typing import (
44
36
  )
45
37
 
46
38
  # ---- Common 3rd-party dependencies --------------------------
47
- import pandas as pd
48
- import geopandas as gpd
49
- import pytesseract
50
- import pdfplumber
51
- import PyPDF2
52
- import ezodf
53
39
  from pdf2image import convert_from_path
54
40
  from werkzeug.utils import secure_filename
55
41
  from werkzeug.datastructures import FileStorage
56
42
 
57
43
  # ---- Helpers ------------------------------------------------
58
- import textwrap as tw
59
44
  from pprint import pprint
60
45
 
61
46
  # ============================================================
@@ -1,13 +1,8 @@
1
- from .imports import *
2
- from ...string_clean import eatAll
3
1
  from ...list_utils import make_list
4
2
  from ...type_utils import get_media_exts, is_media_type, MIME_TYPES, is_str
5
3
  from ...ssh_utils import *
6
4
  from ...env_utils import *
7
- from ...read_write_utils import *
8
- from ...abstract_classes import SingletonMeta
5
+ from ...read_write_utils import read_from_file,write_to_file
9
6
  from ...log_utils import get_logFile
10
- from ...class_utils import get_caller, get_caller_path, get_caller_dir
11
- from ...ssh_utils import run_cmd
7
+ from ...class_utils import get_caller, get_caller_path, get_caller_dir,SingletonMeta,run_pruned_func
12
8
 
13
- __all__ = [name for name in globals() if not name.startswith("_")]
@@ -0,0 +1,12 @@
1
+ from .imports import *
2
+ from ...string_clean import eatAll
3
+ from ...list_utils import make_list
4
+ from ...type_utils import get_media_exts, is_media_type, MIME_TYPES, is_str
5
+ from ...ssh_utils import *
6
+ from ...env_utils import *
7
+ from ...read_write_utils import *
8
+ from ...abstract_classes import SingletonMeta
9
+ from ...log_utils import get_logFile
10
+ from ...class_utils import get_caller, get_caller_path, get_caller_dir
11
+ from ...ssh_utils import run_cmd
12
+
@@ -0,0 +1,8 @@
1
+ from .file_filters import *
2
+ from .filter_params import *
3
+ from .map_utils import *
4
+ from .pdf_utils import *
5
+ from .file_reader import *
6
+ from .find_collect import *
7
+ from .initFunctionsGen import call_for_all_tabs,get_for_all_tabs
8
+