abstract-utilities 0.2.2.513__py3-none-any.whl → 0.2.2.627__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.
Files changed (73) hide show
  1. abstract_utilities/__init__.py +11 -3
  2. abstract_utilities/class_utils/caller_utils.py +19 -0
  3. abstract_utilities/class_utils/global_utils.py +35 -20
  4. abstract_utilities/class_utils/imports/imports.py +1 -1
  5. abstract_utilities/directory_utils/__init__.py +2 -4
  6. abstract_utilities/directory_utils/imports/__init__.py +2 -0
  7. abstract_utilities/directory_utils/imports/imports.py +1 -0
  8. abstract_utilities/directory_utils/imports/module_imports.py +2 -0
  9. abstract_utilities/directory_utils/src/__init__.py +4 -0
  10. abstract_utilities/directory_utils/src/directory_utils.py +110 -0
  11. abstract_utilities/directory_utils/src/name_utils.py +43 -0
  12. abstract_utilities/directory_utils/src/size_utils.py +57 -0
  13. abstract_utilities/directory_utils/src/utils.py +116 -0
  14. abstract_utilities/file_utils/imports/constants.py +81 -7
  15. abstract_utilities/file_utils/imports/imports.py +0 -4
  16. abstract_utilities/file_utils/imports/module_imports.py +1 -1
  17. abstract_utilities/file_utils/src/__init__.py +2 -4
  18. abstract_utilities/file_utils/src/file_filters/__init__.py +4 -0
  19. abstract_utilities/file_utils/src/file_filters/ensure_utils.py +118 -0
  20. abstract_utilities/file_utils/src/file_filters/filter_params.py +86 -0
  21. abstract_utilities/file_utils/src/file_filters/filter_utils.py +78 -0
  22. abstract_utilities/file_utils/src/file_filters/predicate_utils.py +116 -0
  23. abstract_utilities/file_utils/src/file_filters.py +114 -47
  24. abstract_utilities/file_utils/src/file_reader.py +0 -64
  25. abstract_utilities/file_utils/src/file_utils.py +7 -130
  26. abstract_utilities/file_utils/src/filter_params.py +128 -86
  27. abstract_utilities/file_utils/src/find_collect.py +85 -165
  28. abstract_utilities/file_utils/src/find_content.py +210 -0
  29. abstract_utilities/file_utils/src/initFunctionsGen.py +35 -28
  30. abstract_utilities/file_utils/src/initFunctionsGens.py +280 -0
  31. abstract_utilities/file_utils/src/reader_utils/__init__.py +4 -0
  32. abstract_utilities/file_utils/src/reader_utils/directory_reader.py +53 -0
  33. abstract_utilities/file_utils/src/reader_utils/file_reader.py +543 -0
  34. abstract_utilities/file_utils/src/reader_utils/file_readers.py +376 -0
  35. abstract_utilities/file_utils/src/reader_utils/imports.py +18 -0
  36. abstract_utilities/file_utils/src/reader_utils/pdf_utils.py +300 -0
  37. abstract_utilities/file_utils (2)/__init__.py +2 -0
  38. abstract_utilities/file_utils (2)/imports/__init__.py +2 -0
  39. abstract_utilities/file_utils (2)/imports/constants.py +118 -0
  40. abstract_utilities/file_utils (2)/imports/imports/__init__.py +3 -0
  41. abstract_utilities/file_utils (2)/imports/imports/constants.py +119 -0
  42. abstract_utilities/file_utils (2)/imports/imports/imports.py +46 -0
  43. abstract_utilities/file_utils (2)/imports/imports/module_imports.py +8 -0
  44. abstract_utilities/file_utils (2)/imports/utils/__init__.py +3 -0
  45. abstract_utilities/file_utils (2)/imports/utils/classes.py +379 -0
  46. abstract_utilities/file_utils (2)/imports/utils/clean_imps.py +155 -0
  47. abstract_utilities/file_utils (2)/imports/utils/filter_utils.py +341 -0
  48. abstract_utilities/file_utils (2)/src/__init__.py +8 -0
  49. abstract_utilities/file_utils (2)/src/file_filters.py +155 -0
  50. abstract_utilities/file_utils (2)/src/file_reader.py +604 -0
  51. abstract_utilities/file_utils (2)/src/find_collect.py +258 -0
  52. abstract_utilities/file_utils (2)/src/initFunctionsGen.py +286 -0
  53. abstract_utilities/file_utils (2)/src/map_utils.py +28 -0
  54. abstract_utilities/file_utils (2)/src/pdf_utils.py +300 -0
  55. abstract_utilities/import_utils/circular_import_finder.py +222 -0
  56. abstract_utilities/import_utils/circular_import_finder2.py +118 -0
  57. abstract_utilities/import_utils/imports/module_imports.py +3 -1
  58. abstract_utilities/import_utils/src/clean_imports.py +156 -25
  59. abstract_utilities/import_utils/src/dot_utils.py +11 -0
  60. abstract_utilities/import_utils/src/extract_utils.py +4 -0
  61. abstract_utilities/import_utils/src/import_functions.py +66 -2
  62. abstract_utilities/import_utils/src/pkg_utils.py +58 -4
  63. abstract_utilities/import_utils/src/sysroot_utils.py +56 -1
  64. abstract_utilities/log_utils/log_file.py +73 -24
  65. abstract_utilities/parse_utils/parse_utils.py +23 -0
  66. abstract_utilities/path_utils/path_utils.py +25 -23
  67. abstract_utilities/read_write_utils/imports/imports.py +1 -1
  68. abstract_utilities/read_write_utils/read_write_utils.py +99 -31
  69. abstract_utilities/safe_utils/safe_utils.py +30 -0
  70. {abstract_utilities-0.2.2.513.dist-info → abstract_utilities-0.2.2.627.dist-info}/METADATA +1 -1
  71. {abstract_utilities-0.2.2.513.dist-info → abstract_utilities-0.2.2.627.dist-info}/RECORD +73 -32
  72. {abstract_utilities-0.2.2.513.dist-info → abstract_utilities-0.2.2.627.dist-info}/WHEEL +0 -0
  73. {abstract_utilities-0.2.2.513.dist-info → abstract_utilities-0.2.2.627.dist-info}/top_level.txt +0 -0
@@ -34,8 +34,7 @@ from .json_utils import (unified_json_loader,
34
34
  get_result_from_data,
35
35
  flatten_json
36
36
  )
37
- from .read_write_utils import (read_from_file,
38
- write_to_file)
37
+
39
38
  from .directory_utils import *
40
39
  from .path_utils import *
41
40
  from .file_utils import *
@@ -108,7 +107,8 @@ from .parse_utils import (num_tokens_from_string,
108
107
  chunk_any_to_tokens,
109
108
  detect_language_from_text,
110
109
  chunk_by_language_context,
111
- search_code)
110
+ search_code,
111
+ get_within_quotes)
112
112
 
113
113
  from .log_utils import get_caller_info,get_logFile,print_or_log,get_json_call_response,initialize_call_log
114
114
  from .error_utils import try_func
@@ -119,3 +119,11 @@ from .path_utils import *
119
119
  from .file_utils import *
120
120
  from .string_utils import *
121
121
  from .import_utils import *
122
+ from .read_write_utils import (read_from_file,
123
+ write_to_file,
124
+ make_dirs,
125
+ make_dirs,
126
+ copy_files,
127
+ make_path,
128
+ run_cmd
129
+ )
@@ -1,4 +1,23 @@
1
1
  from .imports import *
2
+
3
+ def get_initial_caller() -> str:
4
+ """
5
+ Return the TRUE original caller: the entrypoint script that launched the program.
6
+ """
7
+ main_mod = sys.modules.get('__main__')
8
+
9
+ # interactive environments (REPL) may have no __file__
10
+ if not main_mod or not hasattr(main_mod, '__file__'):
11
+ return None
12
+
13
+ return os.path.realpath(main_mod.__file__)
14
+ def get_initial_caller_dir() -> str:
15
+ """
16
+ Return the directory of the TRUE original entrypoint script.
17
+ """
18
+ caller = get_initial_caller()
19
+ return os.path.dirname(caller) if caller else None
20
+
2
21
  def get_caller(i: Optional[int] = None) -> str:
3
22
  """
4
23
  Return the filename of the calling frame.
@@ -1,3 +1,22 @@
1
+ import importlib, sys,os
2
+ from .caller_utils import get_initial_caller
3
+ def file_to_module_name(path):
4
+ path = os.path.realpath(path)
5
+ # Find a path that exists in sys.path
6
+ for base in sys.path:
7
+ base = os.path.realpath(base)
8
+ if path.startswith(base):
9
+ rel = os.path.relpath(path, base)
10
+ mod = os.path.splitext(rel)[0]
11
+ return mod.replace(os.sep, ".")
12
+ # fallback (never should be used)
13
+ return os.path.splitext(os.path.basename(path))[0]
14
+ def get_globals_from_path(module_path: str=None):
15
+ module_path = module_path or get_initial_caller()
16
+ module_name = file_to_module_name(module_path)
17
+ if module_name not in sys.modules:
18
+ importlib.import_module(module_name)
19
+ return sys.modules[module_name].__dict__
1
20
  def global_registry(name:str,glob:dict):
2
21
  global_ledger = if_none_default(string='global_ledger',glob=globals(),default={"registry_names":[],"registry_index":[]})
3
22
  if name not in global_ledger['registry_names']:
@@ -31,26 +50,22 @@ def return_globals() -> dict:
31
50
  dict: The global variables dictionary.
32
51
  """
33
52
  return globals()
34
- def change_glob(var: str, val: any, glob: dict = return_globals()) -> any:
35
- """
36
- Changes the value of a global variable.
37
-
38
- Args:
39
- var (str): The name of the global variable.
40
- val (any): The new value.
41
- glob (dict, optional): The dictionary of global variables. Defaults to the current globals.
42
-
43
- Returns:
44
- any: The new value of the variable.
45
- """
53
+ def get_true_globals():
54
+ return sys.modules['__main__'].__dict__
55
+ def change_glob(var: str, val: any, glob: dict = None) -> any:
56
+ if glob is None:
57
+ glob = get_true_globals()
46
58
  glob[var] = val
47
59
  return val
48
- def get_globes(string:str='',glob:dict=return_globals()):
49
- if string in glob:
50
- return glob[string]
51
- def if_none_default(string:str, default:any,glob:dict=return_globals()):
52
- piece = get_globes(string=string,glob=glob)
53
- if piece is None:
54
- piece = default
55
- return change_glob(var=string,val=piece,glob=glob)
56
60
 
61
+ def get_globes(string: str='', glob: dict=None):
62
+ if glob is None:
63
+ glob = get_true_globals()
64
+ return glob.get(string)
65
+ def if_none_default(string: str, default: any, glob: dict=None, typ=None):
66
+ if glob is None:
67
+ glob = get_true_globals()
68
+ piece = get_globes(string=string, glob=glob)
69
+ if piece is None or (typ and not isinstance(piece, typ)):
70
+ piece = default
71
+ return change_glob(var=string, val=piece, glob=glob)
@@ -1,2 +1,2 @@
1
- from ...imports import inspect,os,json,functools,inspect,glob
1
+ from ...imports import inspect,os,json,functools,inspect,glob,sys
2
2
  from typing import *
@@ -1,4 +1,2 @@
1
- from .directory_utils import *
2
- from .name_utils import *
3
- from .utils import *
4
- from .size_utils import *
1
+ from .imports import *
2
+ from .src import *
@@ -0,0 +1,2 @@
1
+ from .imports import *
2
+ from .module_imports import *
@@ -0,0 +1 @@
1
+ from ...imports import os,shlex
@@ -0,0 +1,2 @@
1
+ from ...safe_utils import safe_join
2
+ from ...ssh_utils import is_file
@@ -0,0 +1,4 @@
1
+ from .directory_utils import *
2
+ from .name_utils import *
3
+ from .utils import *
4
+ from .size_utils import *
@@ -0,0 +1,110 @@
1
+ from pathlib import Path
2
+ from .utils import *
3
+
4
+ def get_shortest_path(*args):
5
+ shortest = None
6
+ args = {arg:str(arg).split('/') for arg in args if arg}
7
+ for path,spl in args.items():
8
+ if shortest is None or (len(spl)<len(shortest[-1])):
9
+ shortest=[path,spl]
10
+ return shortest[0]
11
+ def get_common_root(paths):
12
+ """
13
+ Compute the deepest common parent directory of all sysroots.
14
+ """
15
+ paths = [Path(p).resolve() for p in paths]
16
+ common = os.path.commonpath(paths)
17
+ return common
18
+
19
+ def get_dirs(path):
20
+ """
21
+ Get List of Immediate Subdirectories in a Path
22
+
23
+ This function uses the os.walk method to traverse through a directory tree and returns a list of immediate subdirectories
24
+ within the specified path.
25
+
26
+ Parameters:
27
+ - path (str): The path for which subdirectories need to be retrieved.
28
+
29
+ Returns:
30
+ - subdirectories (list): A list of immediate subdirectories within the specified path.
31
+
32
+ Example:
33
+ subdirs = get_dirs("/path/to/directory")
34
+ print("Immediate Subdirectories:", subdirs)
35
+ """
36
+ from os import walk
37
+ for (dirpath, dirnames, filenames) in walk(path):
38
+ return dirnames
39
+ def get_directory(file_path: str) -> str:
40
+ """
41
+ Extracts and returns the directory path from a given file path.
42
+
43
+ Args:
44
+ file_path (str): A string representing the file path.
45
+
46
+ Returns:
47
+ str: The directory path extracted from the file path.
48
+ """
49
+ return os.path.dirname(file_path)
50
+ def if_not_last_child_join(path:str,child:str):
51
+ """
52
+ Adds a child path to the given path if it's not already present at the end.
53
+
54
+ Args:
55
+ path (str): The parent path.
56
+ child (str): The child path to add.
57
+
58
+ Returns:
59
+ str: The updated path.
60
+ """
61
+ if path.endswith(child):
62
+ return path
63
+ return simple_path_join(path, child)
64
+ def createFolds(ls: list) -> None:
65
+ """
66
+ Creates multiple directories.
67
+
68
+ Args:
69
+ ls (list): The list of directory paths to create.
70
+ """
71
+ for k in range(len(ls)):
72
+ mkdirs(ls[k])
73
+ def list_directory_contents(path: str) -> list:
74
+ """Returns a list of directory contents or a list with a single file, if the path is a file.
75
+
76
+ Args:
77
+ path (str): The path of the directory or file.
78
+
79
+ Returns:
80
+ list: A list of directory contents or a list with a single file path.
81
+ """
82
+ if is_file(path):
83
+ return [path]
84
+ elif is_valid_path(path):
85
+ return os.listdir(path)
86
+ return [path]
87
+ def is_string_in_dir(path,strings,**kwargs):
88
+ dirname = path
89
+ if is_file(path,**kwargs):
90
+ dirname = os.path.dirname(path)
91
+ pieces = [pa for pa in dirname.split('/') if pa and pa in strings]
92
+ if pieces:
93
+ return True
94
+ return False
95
+ def raw_create_dirs(*paths):
96
+ """Recursively create all directories along the given path."""
97
+ full_path = os.path.abspath(safe_join(*paths))
98
+ sub_parts = [p for p in full_path.split(os.sep) if p]
99
+
100
+ current_path = "/" if full_path.startswith(os.sep) else ""
101
+ for part in sub_parts:
102
+ current_path = safe_join(current_path, part)
103
+ os.makedirs(current_path, exist_ok=True)
104
+ return full_path
105
+
106
+ mkdirs=raw_create_dirs
107
+ makedirs = mkdirs
108
+ make_dirs = makedirs
109
+ makeAllDirs = raw_create_dirs
110
+
@@ -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
+
@@ -1,15 +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]
7
11
  allowed_types: Set[str]
8
12
  exclude_types: Set[str]
9
13
  allowed_dirs: List[str] = field(default_factory=list)
10
14
  exclude_dirs: List[str] = field(default_factory=list)
11
15
  allowed_patterns: List[str] = field(default_factory=list)
12
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
+ # -------------------------
13
38
  DEFAULT_ALLOWED_EXTS: Set[str] = {
14
39
  ".py", ".pyw", # python
15
40
  ".js", ".jsx", ".ts", ".tsx", ".mjs", # JS/TS
@@ -27,11 +52,15 @@ DEFAULT_EXCLUDE_TYPES: Set[str] = {
27
52
  }
28
53
 
29
54
  # never want these—even if they sneak into ALLOWED
30
- _unallowed = set(get_media_exts(DEFAULT_EXCLUDE_TYPES)) | {'.bak', '.shp', '.cpg', '.dbf', '.shx','.geojson',".pyc",'.shx','.geojson','.prj','.sbn','.sbx'}
31
- 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}
32
60
 
33
61
  DEFAULT_EXCLUDE_DIRS: Set[str] = {
34
- "node_modules", "old","__pycache__", "backups", "backup", "backs", "trash", "depriciated", "old", "__init__"
62
+ "node_modules", "old","__pycache__", "backups", "backup",
63
+ "backs", "trash", "depriciated", "old", "__init__"
35
64
  }
36
65
 
37
66
  DEFAULT_EXCLUDE_PATTERNS: Set[str] = {
@@ -40,6 +69,51 @@ DEFAULT_EXCLUDE_PATTERNS: Set[str] = {
40
69
  REMOTE_RE = re.compile(r"^(?P<host>[^:\s]+@[^:\s]+):(?P<path>/.*)$")
41
70
  AllowedPredicate = Optional[Callable[[str], bool]]
42
71
  DEFAULT_EXCLUDE_FILE_PATTERNS=DEFAULT_EXCLUDE_PATTERNS
43
- DEFAULT_ALLOWED_PATTENS="*"
44
- DEFAULT_ALLOWED_DIRS="*"
45
- DEFAULT_ALLOWED_TYPES="*"
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
+
@@ -8,10 +8,6 @@
8
8
 
9
9
  from ...imports import *
10
10
  from pathlib import Path
11
-
12
-
13
-
14
-
15
11
  from typing import *
16
12
 
17
13
  from typing import *
@@ -4,5 +4,5 @@ from ...ssh_utils import *
4
4
  from ...env_utils import *
5
5
  from ...read_write_utils import read_from_file,write_to_file
6
6
  from ...log_utils import get_logFile
7
- from ...class_utils import get_caller, get_caller_path, get_caller_dir,SingletonMeta,run_pruned_func
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
8
8
 
@@ -1,9 +1,7 @@
1
1
  from .file_filters import *
2
- from .file_utils import *
3
- from .filter_params import *
4
2
  from .map_utils import *
5
- from .pdf_utils import *
6
- from .file_reader import *
3
+ from .reader_utils import *
7
4
  from .find_collect import *
5
+ from .find_content import *
8
6
  from .initFunctionsGen import call_for_all_tabs,get_for_all_tabs
9
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 *