abstract-utilities 0.2.2.486__py3-none-any.whl → 0.2.2.593__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 (202) 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 +53 -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 +57 -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 +108 -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/type_checks.py +2 -1
  35. abstract_utilities/file_utils/imports/constants.py +84 -4
  36. abstract_utilities/file_utils/imports/imports.py +2 -21
  37. abstract_utilities/file_utils/imports/module_imports.py +2 -7
  38. abstract_utilities/file_utils/module_imports.py +12 -0
  39. abstract_utilities/file_utils/src/__init__.py +7 -0
  40. abstract_utilities/file_utils/src/file_filters/__init__.py +4 -0
  41. abstract_utilities/file_utils/src/file_filters/ensure_utils.py +118 -0
  42. abstract_utilities/file_utils/src/file_filters/filter_params.py +86 -0
  43. abstract_utilities/file_utils/src/file_filters/filter_utils.py +78 -0
  44. abstract_utilities/file_utils/src/file_filters/predicate_utils.py +114 -0
  45. abstract_utilities/file_utils/src/file_filters.py +177 -0
  46. abstract_utilities/file_utils/src/file_reader.py +543 -0
  47. abstract_utilities/file_utils/src/file_utils.py +156 -0
  48. abstract_utilities/file_utils/src/filter_params.py +197 -0
  49. abstract_utilities/file_utils/src/find_collect.py +190 -0
  50. abstract_utilities/file_utils/src/find_content.py +210 -0
  51. abstract_utilities/file_utils/src/initFunctionsGen.py +280 -0
  52. abstract_utilities/file_utils/src/map_utils.py +29 -0
  53. abstract_utilities/file_utils/src/pdf_utils.py +300 -0
  54. abstract_utilities/file_utils/src/reader_utils/__init__.py +4 -0
  55. abstract_utilities/file_utils/src/reader_utils/directory_reader.py +53 -0
  56. abstract_utilities/file_utils/src/reader_utils/file_reader.py +543 -0
  57. abstract_utilities/file_utils/src/reader_utils/file_readers.py +376 -0
  58. abstract_utilities/file_utils/src/reader_utils/imports.py +18 -0
  59. abstract_utilities/file_utils/src/reader_utils/pdf_utils.py +300 -0
  60. abstract_utilities/file_utils/src/type_checks.py +91 -0
  61. abstract_utilities/file_utils (2)/__init__.py +2 -0
  62. abstract_utilities/file_utils (2)/imports/__init__.py +2 -0
  63. abstract_utilities/file_utils (2)/imports/constants.py +118 -0
  64. abstract_utilities/file_utils (2)/imports/imports/__init__.py +3 -0
  65. abstract_utilities/file_utils (2)/imports/imports/constants.py +119 -0
  66. abstract_utilities/file_utils (2)/imports/imports/imports.py +46 -0
  67. abstract_utilities/file_utils (2)/imports/imports/module_imports.py +8 -0
  68. abstract_utilities/file_utils (2)/imports/utils/__init__.py +3 -0
  69. abstract_utilities/file_utils (2)/imports/utils/classes.py +379 -0
  70. abstract_utilities/file_utils (2)/imports/utils/clean_imps.py +155 -0
  71. abstract_utilities/file_utils (2)/imports/utils/filter_utils.py +341 -0
  72. abstract_utilities/file_utils (2)/src/__init__.py +8 -0
  73. abstract_utilities/file_utils (2)/src/file_filters.py +155 -0
  74. abstract_utilities/file_utils (2)/src/file_reader.py +604 -0
  75. abstract_utilities/file_utils (2)/src/find_collect.py +258 -0
  76. abstract_utilities/file_utils (2)/src/initFunctionsGen.py +286 -0
  77. abstract_utilities/file_utils (2)/src/map_utils.py +28 -0
  78. abstract_utilities/file_utils (2)/src/pdf_utils.py +300 -0
  79. abstract_utilities/hash_utils/__init__.py +2 -0
  80. abstract_utilities/hash_utils/hash_utils.py +5 -0
  81. abstract_utilities/hash_utils/imports/__init__.py +2 -0
  82. abstract_utilities/hash_utils/imports/imports.py +1 -0
  83. abstract_utilities/hash_utils/imports/module_imports.py +0 -0
  84. abstract_utilities/history_utils/__init__.py +2 -0
  85. abstract_utilities/history_utils/history_utils.py +37 -0
  86. abstract_utilities/history_utils/imports/__init__.py +2 -0
  87. abstract_utilities/history_utils/imports/imports.py +1 -0
  88. abstract_utilities/history_utils/imports/module_imports.py +0 -0
  89. abstract_utilities/import_utils/__init__.py +2 -0
  90. abstract_utilities/import_utils/circular_import_finder.py +222 -0
  91. abstract_utilities/import_utils/circular_import_finder2.py +118 -0
  92. abstract_utilities/import_utils/imports/__init__.py +4 -0
  93. abstract_utilities/import_utils/imports/constants.py +2 -0
  94. abstract_utilities/import_utils/imports/imports.py +4 -0
  95. abstract_utilities/import_utils/imports/module_imports.py +8 -0
  96. abstract_utilities/import_utils/imports/utils.py +30 -0
  97. abstract_utilities/import_utils/src/__init__.py +7 -0
  98. abstract_utilities/import_utils/src/clean_imports.py +278 -0
  99. abstract_utilities/import_utils/src/dot_utils.py +80 -0
  100. abstract_utilities/import_utils/src/extract_utils.py +46 -0
  101. abstract_utilities/import_utils/src/import_functions.py +90 -0
  102. abstract_utilities/import_utils/src/import_utils.py +299 -0
  103. abstract_utilities/import_utils/src/package_utils/__init__.py +139 -0
  104. abstract_utilities/import_utils/src/package_utils/context_utils.py +27 -0
  105. abstract_utilities/import_utils/src/package_utils/import_collectors.py +53 -0
  106. abstract_utilities/import_utils/src/package_utils/path_utils.py +28 -0
  107. abstract_utilities/import_utils/src/package_utils/safe_import.py +27 -0
  108. abstract_utilities/import_utils/src/package_utils.py +140 -0
  109. abstract_utilities/import_utils/src/package_utilss/__init__.py +139 -0
  110. abstract_utilities/import_utils/src/package_utilss/context_utils.py +27 -0
  111. abstract_utilities/import_utils/src/package_utilss/import_collectors.py +53 -0
  112. abstract_utilities/import_utils/src/package_utilss/path_utils.py +28 -0
  113. abstract_utilities/import_utils/src/package_utilss/safe_import.py +27 -0
  114. abstract_utilities/import_utils/src/pkg_utils.py +194 -0
  115. abstract_utilities/import_utils/src/sysroot_utils.py +112 -0
  116. abstract_utilities/imports.py +18 -0
  117. abstract_utilities/json_utils/__init__.py +2 -0
  118. abstract_utilities/json_utils/imports/__init__.py +2 -0
  119. abstract_utilities/json_utils/imports/imports.py +2 -0
  120. abstract_utilities/json_utils/imports/module_imports.py +5 -0
  121. abstract_utilities/json_utils/json_utils.py +743 -0
  122. abstract_utilities/list_utils/__init__.py +2 -0
  123. abstract_utilities/list_utils/imports/__init__.py +2 -0
  124. abstract_utilities/list_utils/imports/imports.py +1 -0
  125. abstract_utilities/list_utils/imports/module_imports.py +0 -0
  126. abstract_utilities/list_utils/list_utils.py +199 -0
  127. abstract_utilities/log_utils/__init__.py +5 -0
  128. abstract_utilities/log_utils/abstractLogManager.py +64 -0
  129. abstract_utilities/log_utils/call_response.py +68 -0
  130. abstract_utilities/log_utils/imports/__init__.py +2 -0
  131. abstract_utilities/log_utils/imports/imports.py +7 -0
  132. abstract_utilities/log_utils/imports/module_imports.py +2 -0
  133. abstract_utilities/log_utils/log_file.py +59 -0
  134. abstract_utilities/log_utils/logger_callable.py +49 -0
  135. abstract_utilities/math_utils/__init__.py +2 -0
  136. abstract_utilities/math_utils/imports/__init__.py +2 -0
  137. abstract_utilities/math_utils/imports/imports.py +2 -0
  138. abstract_utilities/math_utils/imports/module_imports.py +1 -0
  139. abstract_utilities/math_utils/math_utils.py +208 -0
  140. abstract_utilities/parse_utils/__init__.py +2 -0
  141. abstract_utilities/parse_utils/imports/__init__.py +3 -0
  142. abstract_utilities/parse_utils/imports/constants.py +10 -0
  143. abstract_utilities/parse_utils/imports/imports.py +2 -0
  144. abstract_utilities/parse_utils/imports/module_imports.py +4 -0
  145. abstract_utilities/parse_utils/parse_utils.py +516 -0
  146. abstract_utilities/path_utils/__init__.py +2 -0
  147. abstract_utilities/path_utils/imports/__init__.py +3 -0
  148. abstract_utilities/path_utils/imports/imports.py +1 -0
  149. abstract_utilities/path_utils/imports/module_imports.py +8 -0
  150. abstract_utilities/path_utils/path_utils.py +253 -0
  151. abstract_utilities/path_utils.py +95 -14
  152. abstract_utilities/read_write_utils/__init__.py +1 -0
  153. abstract_utilities/read_write_utils/imports/__init__.py +2 -0
  154. abstract_utilities/read_write_utils/imports/imports.py +2 -0
  155. abstract_utilities/read_write_utils/imports/module_imports.py +5 -0
  156. abstract_utilities/read_write_utils/read_write_utils.py +338 -0
  157. abstract_utilities/read_write_utils.py +110 -60
  158. abstract_utilities/safe_utils/__init__.py +2 -0
  159. abstract_utilities/safe_utils/imports/__init__.py +3 -0
  160. abstract_utilities/safe_utils/imports/imports.py +2 -0
  161. abstract_utilities/safe_utils/imports/module_imports.py +2 -0
  162. abstract_utilities/safe_utils/safe_utils.py +166 -0
  163. abstract_utilities/ssh_utils/__init__.py +3 -1
  164. abstract_utilities/ssh_utils/classes.py +0 -1
  165. abstract_utilities/ssh_utils/cmd_utils.py +207 -0
  166. abstract_utilities/ssh_utils/imports/__init__.py +3 -0
  167. abstract_utilities/ssh_utils/imports/imports.py +5 -0
  168. abstract_utilities/ssh_utils/imports/module_imports.py +6 -0
  169. abstract_utilities/ssh_utils/imports/utils.py +189 -0
  170. abstract_utilities/ssh_utils/pexpect_utils.py +11 -18
  171. abstract_utilities/ssh_utils/type_checks.py +92 -0
  172. abstract_utilities/string_utils/__init__.py +4 -0
  173. abstract_utilities/string_utils/clean_utils.py +28 -0
  174. abstract_utilities/string_utils/eat_utils.py +103 -0
  175. abstract_utilities/string_utils/imports/__init__.py +3 -0
  176. abstract_utilities/string_utils/imports/imports.py +2 -0
  177. abstract_utilities/string_utils/imports/module_imports.py +2 -0
  178. abstract_utilities/string_utils/imports/utils.py +81 -0
  179. abstract_utilities/string_utils/replace_utils.py +27 -0
  180. abstract_utilities/thread_utils/__init__.py +2 -0
  181. abstract_utilities/thread_utils/imports/__init__.py +2 -0
  182. abstract_utilities/thread_utils/imports/imports.py +2 -0
  183. abstract_utilities/thread_utils/imports/module_imports.py +2 -0
  184. abstract_utilities/thread_utils/thread_utils.py +140 -0
  185. abstract_utilities/time_utils/__init__.py +2 -0
  186. abstract_utilities/time_utils/imports/__init__.py +2 -0
  187. abstract_utilities/time_utils/imports/imports.py +3 -0
  188. abstract_utilities/time_utils/imports/module_imports.py +1 -0
  189. abstract_utilities/time_utils/time_utils.py +392 -0
  190. abstract_utilities/type_utils/__init__.py +3 -0
  191. abstract_utilities/type_utils/alpha_utils.py +59 -0
  192. abstract_utilities/type_utils/imports/__init__.py +2 -0
  193. abstract_utilities/type_utils/imports/imports.py +4 -0
  194. abstract_utilities/type_utils/imports/module_imports.py +1 -0
  195. abstract_utilities/type_utils/num_utils.py +19 -0
  196. abstract_utilities/type_utils/type_utils.py +981 -0
  197. {abstract_utilities-0.2.2.486.dist-info → abstract_utilities-0.2.2.593.dist-info}/METADATA +1 -1
  198. abstract_utilities-0.2.2.593.dist-info/RECORD +277 -0
  199. imports/__init__.py +36 -0
  200. abstract_utilities-0.2.2.486.dist-info/RECORD +0 -92
  201. {abstract_utilities-0.2.2.486.dist-info → abstract_utilities-0.2.2.593.dist-info}/WHEEL +0 -0
  202. {abstract_utilities-0.2.2.486.dist-info → abstract_utilities-0.2.2.593.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,43 @@
1
+ from ..imports import *
2
+ from .directory_utils import *
3
+ def get_file_name(file_path: str) -> str:
4
+ """
5
+ Retrieves and returns the base name of a file from a given file path.
6
+
7
+ Args:
8
+ file_path (str): A string representing the file path.
9
+
10
+ Returns:
11
+ str: The base name of the file (without extension).
12
+ """
13
+ return split_text(get_base_name(file_path))[0]
14
+ def get_abs_name_of_this():
15
+ """
16
+ Returns the absolute name of the current module.
17
+
18
+ Returns:
19
+ Path: The absolute name of the current module.
20
+ """
21
+ return os.path.abspath(__name__)
22
+ def sanitize_filename(name: str):
23
+ """
24
+ Sanitize a filename by removing invalid characters.
25
+
26
+ Args:
27
+ name (str): Filename to sanitize.
28
+
29
+ Returns:
30
+ str: Sanitized filename.
31
+ """
32
+ return re.sub(r'[\\/*?:"<>|]', "", name)
33
+ def get_base_name(file_path: str) -> str:
34
+ """
35
+ Extracts and returns the base name of a file from a given file path.
36
+
37
+ Args:
38
+ file_path (str): A string representing the file path.
39
+
40
+ Returns:
41
+ str: The base name of the file.
42
+ """
43
+ return os.path.basename(file_path)
@@ -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 *
@@ -2,7 +2,8 @@ from .imports import *
2
2
 
3
3
  def get_user_pass_host_key(**kwargs):
4
4
  args = ['password','user_at_host','host','key','user']
5
- values,kwargs = get_from_kwargs(*args,**kwargs,del_kwarg=False)
5
+ kwargs['del_kwarg']=kwargs.get('del_kwarg',False)
6
+ values,kwargs = get_from_kwargs(*args,**kwargs)
6
7
  return values
7
8
 
8
9
  # --- Base remote checker -----------------------------------------------------
@@ -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,13 @@
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
14
-
15
-
16
-
17
11
  from typing import *
18
- import re
19
12
 
20
13
  from typing import *
21
14
  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
15
+
26
16
  from datetime import datetime
27
17
 
28
18
  from typing import *
@@ -30,8 +20,6 @@ from werkzeug.utils import secure_filename
30
20
  from werkzeug.datastructures import FileStorage
31
21
  from pdf2image import convert_from_path # only used for OCR fallback
32
22
  # ---- 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
23
 
36
24
  from datetime import datetime
37
25
  from types import ModuleType
@@ -44,18 +32,11 @@ from typing import (
44
32
  )
45
33
 
46
34
  # ---- 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
35
  from pdf2image import convert_from_path
54
36
  from werkzeug.utils import secure_filename
55
37
  from werkzeug.datastructures import FileStorage
56
38
 
57
39
  # ---- Helpers ------------------------------------------------
58
- import textwrap as tw
59
40
  from pprint import pprint
60
41
 
61
42
  # ============================================================
@@ -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 if_none_default,if_none_change,get_caller,get_initial_caller_dir, 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,7 @@
1
+ from .file_filters import *
2
+ from .map_utils import *
3
+ from .reader_utils import *
4
+ from .find_collect import *
5
+ from .find_content import *
6
+ from .initFunctionsGen import call_for_all_tabs,get_for_all_tabs
7
+
@@ -0,0 +1,4 @@
1
+ from .ensure_utils import *
2
+ from .filter_params import *
3
+ from .filter_utils import *
4
+ from .predicate_utils import *