abstract-utilities 0.2.2.593__py3-none-any.whl → 0.2.2.679__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 (51) hide show
  1. abstract_utilities/__init__.py +18 -6
  2. abstract_utilities/class_utils/abstract_classes.py +104 -34
  3. abstract_utilities/class_utils/caller_utils.py +39 -0
  4. abstract_utilities/class_utils/global_utils.py +35 -21
  5. abstract_utilities/class_utils/imports/imports.py +1 -1
  6. abstract_utilities/directory_utils/src/directory_utils.py +2 -0
  7. abstract_utilities/file_utils/imports/classes.py +59 -55
  8. abstract_utilities/file_utils/imports/module_imports.py +1 -1
  9. abstract_utilities/file_utils/src/file_filters/__init__.py +0 -3
  10. abstract_utilities/file_utils/src/file_filters/ensure_utils.py +382 -10
  11. abstract_utilities/file_utils/src/file_filters/filter_params.py +64 -0
  12. abstract_utilities/file_utils/src/file_filters/predicate_utils.py +21 -91
  13. abstract_utilities/file_utils/src/find_collect.py +10 -0
  14. abstract_utilities/file_utils/src/initFunctionsGen.py +36 -23
  15. abstract_utilities/file_utils/src/initFunctionsGens.py +280 -0
  16. abstract_utilities/import_utils/imports/__init__.py +1 -1
  17. abstract_utilities/import_utils/imports/init_imports.py +3 -0
  18. abstract_utilities/import_utils/imports/module_imports.py +2 -1
  19. abstract_utilities/import_utils/imports/utils.py +1 -1
  20. abstract_utilities/import_utils/src/__init__.py +1 -0
  21. abstract_utilities/import_utils/src/extract_utils.py +2 -2
  22. abstract_utilities/import_utils/src/import_functions.py +30 -10
  23. abstract_utilities/import_utils/src/import_utils.py +41 -0
  24. abstract_utilities/import_utils/src/layze_import_utils/__init__.py +2 -0
  25. abstract_utilities/import_utils/src/layze_import_utils/lazy_utils.py +41 -0
  26. abstract_utilities/import_utils/src/layze_import_utils/nullProxy.py +37 -0
  27. abstract_utilities/import_utils/src/nullProxy.py +30 -0
  28. abstract_utilities/import_utils/src/sysroot_utils.py +1 -1
  29. abstract_utilities/imports.py +5 -2
  30. abstract_utilities/json_utils/imports/imports.py +1 -1
  31. abstract_utilities/json_utils/json_utils.py +37 -3
  32. abstract_utilities/list_utils/list_utils.py +3 -0
  33. abstract_utilities/log_utils/log_file.py +137 -34
  34. abstract_utilities/parse_utils/parse_utils.py +23 -0
  35. abstract_utilities/path_utils/imports/module_imports.py +1 -1
  36. abstract_utilities/path_utils/path_utils.py +7 -12
  37. abstract_utilities/read_write_utils/imports/imports.py +1 -1
  38. abstract_utilities/read_write_utils/read_write_utils.py +137 -36
  39. abstract_utilities/type_utils/__init__.py +5 -1
  40. abstract_utilities/type_utils/get_type.py +120 -0
  41. abstract_utilities/type_utils/imports/__init__.py +1 -0
  42. abstract_utilities/type_utils/imports/constants.py +134 -0
  43. abstract_utilities/type_utils/imports/module_imports.py +25 -1
  44. abstract_utilities/type_utils/is_type.py +455 -0
  45. abstract_utilities/type_utils/make_type.py +126 -0
  46. abstract_utilities/type_utils/mime_types.py +68 -0
  47. abstract_utilities/type_utils/type_utils.py +0 -877
  48. {abstract_utilities-0.2.2.593.dist-info → abstract_utilities-0.2.2.679.dist-info}/METADATA +1 -1
  49. {abstract_utilities-0.2.2.593.dist-info → abstract_utilities-0.2.2.679.dist-info}/RECORD +51 -40
  50. {abstract_utilities-0.2.2.593.dist-info → abstract_utilities-0.2.2.679.dist-info}/WHEEL +0 -0
  51. {abstract_utilities-0.2.2.593.dist-info → abstract_utilities-0.2.2.679.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,120 @@
1
+ from .imports import *
2
+ from .alpha_utils import *
3
+ from .num_utils import *
4
+ from .is_type import *
5
+ from .make_type import *
6
+ def get_obj_obj(obj_type: str, obj: any) -> any:
7
+ """
8
+ Returns the object converted according to the given type string.
9
+
10
+ Args:
11
+ obj_type: The string representing the type to convert to.
12
+ obj: The object to convert.
13
+
14
+ Returns:
15
+ any: The object converted to the specified type.
16
+ """
17
+ if obj_type == 'str':
18
+ return make_str(obj)
19
+ elif obj_type == 'bool':
20
+ return make_bool(obj)
21
+ elif obj_type == 'float':
22
+ return make_float(obj)
23
+ elif obj_type == 'int':
24
+ try:
25
+ return int(obj)
26
+ except (TypeError, ValueError):
27
+ return obj
28
+ else:
29
+ return obj
30
+ def get_len_or_num(obj: any) -> int:
31
+ """
32
+ Returns the length of the object if it can be converted to a string, else the integer representation of the object.
33
+
34
+ Args:
35
+ obj: The object to process.
36
+
37
+ Returns:
38
+ int: The length of the object as a string or the integer representation of the object.
39
+ """
40
+ if is_int(obj) or is_float(obj):
41
+ return int(obj)
42
+ else:
43
+ try:
44
+ return len(str(obj))
45
+ except (TypeError, ValueError):
46
+ return 0
47
+ def get_types_list()->list:
48
+ return ['list', 'bool', 'str', 'int', 'float', 'set', 'dict', 'frozenset', 'bytearray', 'bytes', 'memoryview', 'range', 'enumerate', 'zip', 'filter', 'map', 'property', 'slice', 'super', 'type', 'Exception', 'NoneType']
49
+
50
+
51
+ def str_lower(obj):
52
+ try:
53
+ obj=str(obj).lower()
54
+ except Exception as e:
55
+ print(f"{e}")
56
+ return obj
57
+
58
+ def get_bool_response(bool_response,json_data):
59
+ if not is_instance(bool_response,bool):
60
+ try:
61
+ bool_response = json_data.get(bool_response) in [None,'',[],"",{}]
62
+ except:
63
+ pass
64
+ return bool_response
65
+ def get_alphabet_str():
66
+ return 'abcdefghijklmnopqrstuvwxyz'
67
+ def get_alphabet_upper_str():
68
+ alphabet_str = get_alphabet_str()
69
+ return alphabet_str.upper()
70
+ def get_alphabet_comp_str():
71
+ return get_alphabet_str() + get_alphabet_upper_str()
72
+
73
+ def get_alphabet():
74
+ alphabet_str = get_alphabet_str()
75
+ return break_string(alphabet_str)
76
+ def get_alphabet_upper():
77
+ alphabet_upper_str = get_alphabet_upper_str()
78
+ return break_string(alphabet_upper_str)
79
+ def get_alphabet_comp():
80
+ alphabet_comp_str = get_alphabet_comp_str()
81
+ return break_string(alphabet_comp_str)
82
+ def get_numbers_str():
83
+ return '0123457890'
84
+ def get_numbers_int():
85
+ numbers_str = get_numbers_str()
86
+ return [int(number) for number in numbers_str]
87
+ def get_numbers():
88
+ numbers_str = get_numbers_str()
89
+ return break_string(numbers_str)
90
+ def get_numbers_comp():
91
+ numbers_str = get_numbers()
92
+ numbers_int = get_numbers_int()
93
+ return numbers_str + numbers_int
94
+ def break_string(string):
95
+ string_str = str(string)
96
+ return list(string_str)
97
+ def get_alpha_ints(ints=True,alpha=True,lower=True,capitalize=True,string=True,listObj=True):
98
+ objs = [] if listObj else ""
99
+ if ints:
100
+ objs+=getInts(string=string,listObj=listObj)
101
+ if alpha:
102
+ objs+=getAlphas(lower=lower,capitalize=capitalize,listObj=listObj)
103
+ return objs
104
+ def if_true_get_string(data, key):
105
+ return key if data.get(key) else None
106
+ def find_for_string(string, parts):
107
+ return [part for part in parts if string.lower() in str(part).lower()]
108
+
109
+
110
+ def is_strings_in_string(strings, parts):
111
+ strings = make_list(strings)
112
+ for string in strings:
113
+ parts = find_for_string(string, parts)
114
+ if not parts:
115
+ return []
116
+ return parts
117
+ def if_not_bool_default(value,default=None):
118
+ if not isinstance(value,bool):
119
+ value = default
120
+ return value
@@ -1,2 +1,3 @@
1
1
  from .imports import *
2
2
  from .module_imports import *
3
+ from .constants import *
@@ -0,0 +1,134 @@
1
+ from .module_imports import *
2
+ MIME_TYPES = {
3
+ 'image': {
4
+ '.jpg': 'image/jpeg',
5
+ '.jpeg': 'image/jpeg',
6
+ '.png': 'image/png',
7
+ '.gif': 'image/gif',
8
+ '.bmp': 'image/bmp',
9
+ '.tiff': 'image/tiff',
10
+ '.webp': 'image/webp',
11
+ '.svg': 'image/svg+xml',
12
+ '.ico': 'image/vnd.microsoft.icon',
13
+ '.heic': 'image/heic',
14
+ '.psd': 'image/vnd.adobe.photoshop',
15
+ '.raw': 'image/x-raw',
16
+ },
17
+ 'video': {
18
+ '.mp4': 'video/mp4',
19
+ '.webm': 'video/webm',
20
+ '.ogg': 'video/ogg',
21
+ '.mov': 'video/quicktime',
22
+ '.avi': 'video/x-msvideo',
23
+ '.mkv': 'video/x-matroska',
24
+ '.flv': 'video/x-flv',
25
+ '.wmv': 'video/x-ms-wmv',
26
+ '.3gp': 'video/3gpp',
27
+ '.ts': 'video/mp2t',
28
+ '.mpeg': 'video/mpeg',
29
+ '.mpg': 'video/mpg'
30
+ },
31
+ 'audio': {
32
+ '.mp3': 'audio/mpeg',
33
+ '.wav': 'audio/wav',
34
+ '.flac': 'audio/flac',
35
+ '.aac': 'audio/aac',
36
+ '.ogg': 'audio/ogg',
37
+ '.m4a': 'audio/mp4',
38
+ '.opus': 'audio/opus',
39
+ },
40
+ 'document': {
41
+ '.pdf': 'application/pdf',
42
+ '.doc': 'application/msword',
43
+ '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
44
+ '.odt': 'application/vnd.oasis.opendocument.text',
45
+ '.txt': 'text/plain',
46
+ '.rtf': 'application/rtf',
47
+ '.md': 'text/markdown',
48
+ '.markdown': 'text/markdown',
49
+ '.tex': 'application/x-tex',
50
+ '.log': 'text/plain',
51
+ '.json': 'application/json',
52
+ '.xml': 'application/xml',
53
+ '.yaml': 'application/x-yaml',
54
+ '.yml': 'application/x-yaml',
55
+ '.ini': 'text/plain',
56
+ '.cfg': 'text/plain',
57
+ '.toml': 'application/toml',
58
+ '.csv': 'text/csv',
59
+ '.tsv': 'text/tab-separated-values'
60
+ },
61
+ 'presentation': {
62
+ '.ppt': 'application/vnd.ms-powerpoint',
63
+ '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
64
+ '.odp': 'application/vnd.oasis.opendocument.presentation',
65
+ },
66
+ 'spreadsheet': {
67
+ '.xls': 'application/vnd.ms-excel',
68
+ '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
69
+ '.ods': 'application/vnd.oasis.opendocument.spreadsheet',
70
+ '.csv': 'text/csv',
71
+ '.tsv': 'text/tab-separated-values'
72
+ },
73
+ 'code': {
74
+ '.py': 'text/x-python',
75
+ '.java': 'text/x-java-source',
76
+ '.c': 'text/x-c',
77
+ '.cpp': 'text/x-c++',
78
+ '.h': 'text/x-c',
79
+ '.hpp': 'text/x-c++',
80
+ '.js': 'application/javascript',
81
+ '.cjs': 'application/javascript',
82
+ '.mjs': 'application/javascript',
83
+ '.jsx': 'application/javascript',
84
+ '.ts': 'application/typescript',
85
+ '.tsx': 'application/typescript',
86
+ '.rb': 'text/x-ruby',
87
+ '.php': 'application/x-php',
88
+ '.go': 'text/x-go',
89
+ '.rs': 'text/rust',
90
+ '.swift': 'text/x-swift',
91
+ '.kt': 'text/x-kotlin',
92
+ '.sh': 'application/x-shellscript',
93
+ '.bash': 'application/x-shellscript',
94
+ '.ps1': 'application/x-powershell',
95
+ '.sql': 'application/sql',
96
+ '.yml': 'application/x-yaml',
97
+ '.coffee':'text/coffeescript',
98
+ '.lua': 'text/x-lua',
99
+ },
100
+ 'archive': {
101
+ '.zip': 'application/zip',
102
+ '.tar': 'application/x-tar',
103
+ '.gz': 'application/gzip',
104
+ '.tgz': 'application/gzip',
105
+ '.bz2': 'application/x-bzip2',
106
+ '.xz': 'application/x-xz',
107
+ '.rar': 'application/vnd.rar',
108
+ '.7z': 'application/x-7z-compressed',
109
+ '.iso': 'application/x-iso9660-image',
110
+ '.dmg': 'application/x-apple-diskimage',
111
+ '.jar': 'application/java-archive',
112
+ '.war': 'application/java-archive',
113
+ '.whl': 'application/python-wheel',
114
+ '.egg': 'application/python-egg',
115
+ },
116
+ 'font': {
117
+ '.ttf': 'font/ttf',
118
+ '.otf': 'font/otf',
119
+ '.woff': 'font/woff',
120
+ '.woff2': 'font/woff2',
121
+ '.eot': 'application/vnd.ms-fontobject'
122
+ },
123
+ 'executable': {
124
+ '.exe': 'application/vnd.microsoft.portable-executable',
125
+ '.dll': 'application/vnd.microsoft.portable-executable',
126
+ '.bin': 'application/octet-stream',
127
+ '.deb': 'application/vnd.debian.binary-package',
128
+ '.rpm': 'application/x-rpm'
129
+ }
130
+ }
131
+
132
+ # And just the sets, if you only need to test ext‐membership:
133
+ MEDIA_TYPES = make_key_map(MIME_TYPES)
134
+
@@ -1 +1,25 @@
1
- from ...list_utils import make_list
1
+ def make_list(obj:any) -> list:
2
+ """
3
+ Converts the input object to a list. If the object is already a list, it is returned as is.
4
+
5
+ Args:
6
+ obj: The object to convert.
7
+
8
+ Returns:
9
+ list: The object as a list.
10
+ """
11
+ if isinstance(obj,str):
12
+ if ',' in obj:
13
+ obj = obj.split(',')
14
+ if isinstance(obj,set) or isinstance(obj,tuple):
15
+ return list(obj)
16
+ if isinstance(obj, list):
17
+ return obj
18
+ return [obj]
19
+ def get_keys(mapping,typ=None):
20
+ typ = typ or set
21
+ if isinstance(mapping,dict):
22
+ mapping = mapping.keys()
23
+ return typ(mapping)
24
+ def make_key_map(dict_obj):
25
+ return {k:get_keys(v) for k,v in dict_obj.items()}