abstract-utilities 0.2.2.469__py3-none-any.whl → 0.2.2.470__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.
- abstract_utilities/robust_readers/import_utils/clean_imports.py +6 -99
- abstract_utilities/string_clean.py +40 -1
- abstract_utilities/type_utils.py +25 -1
- {abstract_utilities-0.2.2.469.dist-info → abstract_utilities-0.2.2.470.dist-info}/METADATA +1 -1
- {abstract_utilities-0.2.2.469.dist-info → abstract_utilities-0.2.2.470.dist-info}/RECORD +7 -7
- {abstract_utilities-0.2.2.469.dist-info → abstract_utilities-0.2.2.470.dist-info}/WHEEL +0 -0
- {abstract_utilities-0.2.2.469.dist-info → abstract_utilities-0.2.2.470.dist-info}/top_level.txt +0 -0
|
@@ -1,87 +1,10 @@
|
|
|
1
|
-
from
|
|
1
|
+
from ...read_write_utils import read_from_file,write_to_file
|
|
2
|
+
from ...string_clean import eatAll,eatElse,clean_line
|
|
3
|
+
from ...class_utils import get_caller_path
|
|
4
|
+
from ...list_utils import make_list
|
|
5
|
+
import os
|
|
2
6
|
import_tag = 'import '
|
|
3
7
|
from_tag = 'from '
|
|
4
|
-
def get_caller_path(i=None):
|
|
5
|
-
i = i or 1
|
|
6
|
-
frame = inspect.stack()[i]
|
|
7
|
-
return os.path.abspath(frame.filename)
|
|
8
|
-
def make_list(obj:any) -> list:
|
|
9
|
-
"""
|
|
10
|
-
Converts the input object to a list. If the object is already a list, it is returned as is.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
obj: The object to convert.
|
|
14
|
-
|
|
15
|
-
Returns:
|
|
16
|
-
list: The object as a list.
|
|
17
|
-
"""
|
|
18
|
-
if isinstance(obj,str):
|
|
19
|
-
if ',' in obj:
|
|
20
|
-
obj = obj.split(',')
|
|
21
|
-
if isinstance(obj,set) or isinstance(obj,tuple):
|
|
22
|
-
return list(obj)
|
|
23
|
-
if isinstance(obj, list):
|
|
24
|
-
return obj
|
|
25
|
-
return [obj]
|
|
26
|
-
def getAlphas(lower=True,capitalize=False,listObj=False):
|
|
27
|
-
obj = ''
|
|
28
|
-
alphas = 'abcdefghijklmoprstuvwxyz'
|
|
29
|
-
if lower:
|
|
30
|
-
obj+=alphas
|
|
31
|
-
if capitalize:
|
|
32
|
-
obj+=alphas.upper()
|
|
33
|
-
if listObj:
|
|
34
|
-
obj = list(obj)
|
|
35
|
-
return obj
|
|
36
|
-
def getInts(string=False,listObj=False):
|
|
37
|
-
obj=12345678909
|
|
38
|
-
if string:
|
|
39
|
-
obj = str(obj)
|
|
40
|
-
if listObj:
|
|
41
|
-
obj = list(obj)
|
|
42
|
-
return obj
|
|
43
|
-
def get_alpha_ints(ints=True,alpha=True,lower=True,capitalize=True,string=True,listObj=True):
|
|
44
|
-
objs = [] if listObj else ""
|
|
45
|
-
if ints:
|
|
46
|
-
objs+=getInts(string=string,listObj=listObj)
|
|
47
|
-
if alpha:
|
|
48
|
-
objs+=getAlphas(lower=lower,capitalize=capitalize,listObj=listObj)
|
|
49
|
-
return objs
|
|
50
|
-
def eatElse(
|
|
51
|
-
stringObj,
|
|
52
|
-
chars=None,
|
|
53
|
-
ints=True,
|
|
54
|
-
alpha=True,
|
|
55
|
-
lower=True,
|
|
56
|
-
capitalize=True,
|
|
57
|
-
string=True,
|
|
58
|
-
listObj=True
|
|
59
|
-
):
|
|
60
|
-
alpha_ints = get_alpha_ints(
|
|
61
|
-
ints=True,
|
|
62
|
-
alpha=True,
|
|
63
|
-
lower=True,
|
|
64
|
-
capitalize=True,
|
|
65
|
-
string=True,
|
|
66
|
-
listObj=True
|
|
67
|
-
)
|
|
68
|
-
chars = make_list(chars or [])+alpha_ints
|
|
69
|
-
|
|
70
|
-
while True:
|
|
71
|
-
if stringObj:
|
|
72
|
-
str_0 = stringObj[0] not in chars
|
|
73
|
-
str_1 = stringObj[-1] not in chars
|
|
74
|
-
str_eat = str_0 or str_1
|
|
75
|
-
if not str_eat:
|
|
76
|
-
return stringObj
|
|
77
|
-
if stringObj and str_0:
|
|
78
|
-
stringObj = stringObj[1:] if len(stringObj) !=1 else ""
|
|
79
|
-
if stringObj and str_1:
|
|
80
|
-
stringObj = stringObj[:-1] if len(stringObj) !=1 else ""
|
|
81
|
-
else:
|
|
82
|
-
return stringObj
|
|
83
|
-
def clean_line(line):
|
|
84
|
-
return eatAll(line,[' ','','\t','\n'])
|
|
85
8
|
def is_line_import(line):
|
|
86
9
|
if line and (line.startswith(from_tag) or line.startswith(import_tag)):
|
|
87
10
|
return True
|
|
@@ -92,27 +15,11 @@ def is_line_group_import(line):
|
|
|
92
15
|
return False
|
|
93
16
|
def get_import_pkg(line):
|
|
94
17
|
if is_line_group_import(line):
|
|
95
|
-
|
|
96
18
|
return clean_line(line.split(from_tag)[1].split(import_tag)[0])
|
|
97
19
|
def get_imports_from_import_pkg(line):
|
|
98
20
|
if is_line_group_import(line):
|
|
99
21
|
return get_cleaned_import_list(line,commaClean=True)
|
|
100
|
-
|
|
101
|
-
## dirname = os.path.dirname(file_path)
|
|
102
|
-
## parts = part for part in dirname.split('/') if part]
|
|
103
|
-
## i=0
|
|
104
|
-
## pkg = pkg_name
|
|
105
|
-
## while True:
|
|
106
|
-
## if pkg and pkg.startswith('.'):
|
|
107
|
-
## i +=1
|
|
108
|
-
## pkg=pkg[1:] if len(pkg)>1 else ""
|
|
109
|
-
## else:
|
|
110
|
-
## if i > 1 and len(parts)>=i:
|
|
111
|
-
## pkg = '.'.join(parts[:-i])
|
|
112
|
-
## .{pkg}"
|
|
113
|
-
## parts
|
|
114
|
-
|
|
115
|
-
|
|
22
|
+
|
|
116
23
|
def add_imports_to_import_pkg_js(import_pkg,imports,import_pkg_js=None):
|
|
117
24
|
import_pkg_js = import_pkg_js or {}
|
|
118
25
|
imports = clean_imports(imports)
|
|
@@ -22,6 +22,8 @@ Date: 05/31/2023
|
|
|
22
22
|
Version: 0.1.2
|
|
23
23
|
"""
|
|
24
24
|
import os
|
|
25
|
+
from .list_utils import make_list
|
|
26
|
+
from .type_utils import get_alpha_ints
|
|
25
27
|
def quoteIt(st: str, ls: list) -> str:
|
|
26
28
|
"""
|
|
27
29
|
Quotes specific elements in a string.
|
|
@@ -110,6 +112,42 @@ def eatAll(string: str, list_objects:(str or list)) -> any:
|
|
|
110
112
|
if string and list_objects:
|
|
111
113
|
string = eatOuter(string, list_objects)
|
|
112
114
|
return string
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def eatElse(
|
|
119
|
+
stringObj,
|
|
120
|
+
chars=None,
|
|
121
|
+
ints=True,
|
|
122
|
+
alpha=True,
|
|
123
|
+
lower=True,
|
|
124
|
+
capitalize=True,
|
|
125
|
+
string=True,
|
|
126
|
+
listObj=True
|
|
127
|
+
):
|
|
128
|
+
alpha_ints = get_alpha_ints(
|
|
129
|
+
ints=True,
|
|
130
|
+
alpha=True,
|
|
131
|
+
lower=True,
|
|
132
|
+
capitalize=True,
|
|
133
|
+
string=True,
|
|
134
|
+
listObj=True
|
|
135
|
+
)
|
|
136
|
+
chars = make_list(chars or [])+alpha_ints
|
|
137
|
+
|
|
138
|
+
while True:
|
|
139
|
+
if stringObj:
|
|
140
|
+
str_0 = stringObj[0] not in chars
|
|
141
|
+
str_1 = stringObj[-1] not in chars
|
|
142
|
+
str_eat = str_0 or str_1
|
|
143
|
+
if not str_eat:
|
|
144
|
+
return stringObj
|
|
145
|
+
if stringObj and str_0:
|
|
146
|
+
stringObj = stringObj[1:] if len(stringObj) !=1 else ""
|
|
147
|
+
if stringObj and str_1:
|
|
148
|
+
stringObj = stringObj[:-1] if len(stringObj) !=1 else ""
|
|
149
|
+
else:
|
|
150
|
+
return stringObj
|
|
113
151
|
def safe_split(obj, ls):
|
|
114
152
|
"""
|
|
115
153
|
Safely splits a string using multiple delimiters.
|
|
@@ -185,6 +223,7 @@ def url_join(*paths):
|
|
|
185
223
|
final_path = f"{final_path}/{path}"
|
|
186
224
|
return final_path
|
|
187
225
|
|
|
188
|
-
|
|
226
|
+
def clean_line(line):
|
|
227
|
+
return eatAll(line,[' ','','\t','\n'])
|
|
189
228
|
def capitalize(string):
|
|
190
229
|
return string[:1].upper() + string[1:].lower() if string else string
|
abstract_utilities/type_utils.py
CHANGED
|
@@ -60,6 +60,7 @@ import os
|
|
|
60
60
|
from pathlib import Path
|
|
61
61
|
from typing import Union
|
|
62
62
|
from .list_utils import make_list
|
|
63
|
+
|
|
63
64
|
# A big, but by no means exhaustive, map of extensions to mime‐types by category:
|
|
64
65
|
MIME_TYPES = {
|
|
65
66
|
'image': {
|
|
@@ -936,7 +937,30 @@ def is_any_instance(value):
|
|
|
936
937
|
for each in [dict, list, int, float]:
|
|
937
938
|
if is_instance(value, each):
|
|
938
939
|
return True
|
|
939
|
-
|
|
940
|
+
def getAlphas(lower=True,capitalize=False,listObj=False):
|
|
941
|
+
obj = ''
|
|
942
|
+
alphas = 'abcdefghijklmoprstuvwxyz'
|
|
943
|
+
if lower:
|
|
944
|
+
obj+=alphas
|
|
945
|
+
if capitalize:
|
|
946
|
+
obj+=alphas.upper()
|
|
947
|
+
if listObj:
|
|
948
|
+
obj = list(obj)
|
|
949
|
+
return obj
|
|
950
|
+
def getInts(string=False,listObj=False):
|
|
951
|
+
obj=12345678909
|
|
952
|
+
if string:
|
|
953
|
+
obj = str(obj)
|
|
954
|
+
if listObj:
|
|
955
|
+
obj = list(obj)
|
|
956
|
+
return obj
|
|
957
|
+
def get_alpha_ints(ints=True,alpha=True,lower=True,capitalize=True,string=True,listObj=True):
|
|
958
|
+
objs = [] if listObj else ""
|
|
959
|
+
if ints:
|
|
960
|
+
objs+=getInts(string=string,listObj=listObj)
|
|
961
|
+
if alpha:
|
|
962
|
+
objs+=getAlphas(lower=lower,capitalize=capitalize,listObj=listObj)
|
|
963
|
+
return objs
|
|
940
964
|
# Function: is_number
|
|
941
965
|
# Function: is_str
|
|
942
966
|
# Function: is_int
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: abstract_utilities
|
|
3
|
-
Version: 0.2.2.
|
|
3
|
+
Version: 0.2.2.470
|
|
4
4
|
Summary: abstract_utilities is a collection of utility modules providing a variety of functions to aid in tasks such as data comparison, list manipulation, JSON handling, string manipulation, mathematical computations, and time operations.
|
|
5
5
|
Home-page: https://github.com/AbstractEndeavors/abstract_utilities
|
|
6
6
|
Author: putkoff
|
|
@@ -16,12 +16,12 @@ abstract_utilities/parse_utils.py,sha256=Z5OGRwHuzCzY91fz0JJojk1BPAo1XF2quNNLuBF
|
|
|
16
16
|
abstract_utilities/path_utils.py,sha256=X_U9cPBbNu5Wi0F3hQE0gXQX1gfhzxhxALbairTEOZU,19252
|
|
17
17
|
abstract_utilities/read_write_utils.py,sha256=S8Sj0mtErRze9uOOzdWl2ZreREdXKKQMbyQKC75c_Vc,6921
|
|
18
18
|
abstract_utilities/safe_utils.py,sha256=_uoZny6dJjopVakOiaf0UIZcvRRXMh51FpfDUooe0xY,3733
|
|
19
|
-
abstract_utilities/string_clean.py,sha256
|
|
19
|
+
abstract_utilities/string_clean.py,sha256=oQv85J-mA4sP2NJwbTI-1k0RXw7V0AmqZolYaAZvex4,6916
|
|
20
20
|
abstract_utilities/string_utils.py,sha256=02xdIEDySWEexrtY3skBYOdeDmr3XgE5j1nqAeAv7w8,352
|
|
21
21
|
abstract_utilities/tetsts.py,sha256=PrejTUew5dAAqNb4erMJwfdSHxDyuuHGWY2fMlWk5hk,21
|
|
22
22
|
abstract_utilities/thread_utils.py,sha256=LhE1ylSuOKkkMErBf6SjZprjO_vfh3IKfvNKJQiCxho,5460
|
|
23
23
|
abstract_utilities/time_utils.py,sha256=yikMjn7i-OBKfmOujfNtDz4R0VTMgi3dfQNrCIZUbQU,13052
|
|
24
|
-
abstract_utilities/type_utils.py,sha256=
|
|
24
|
+
abstract_utilities/type_utils.py,sha256=XaaAel9hUKeOzBqSCqJsIC6UiPMXUlhtmU77jOHz8Ek,27676
|
|
25
25
|
abstract_utilities/utils.py,sha256=SCa_-x_wsWrcokQXKwlhalxndxLn5Wg25-zqRdJUmag,185049
|
|
26
26
|
abstract_utilities/cmd_utils/__init__.py,sha256=StTaaB9uzJexvr4TFGVqp_o0_s9T6rQlE3fOZtb_y_0,51
|
|
27
27
|
abstract_utilities/cmd_utils/cmd_utils.py,sha256=n2DEo91J8LWuIJoSoDkWdApUY_8mHrUW3kjEjjF34Io,7876
|
|
@@ -73,7 +73,7 @@ abstract_utilities/robust_readers/__init__.py,sha256=_1vhOG1FJnfrRK0ubkT1v6U6udH
|
|
|
73
73
|
abstract_utilities/robust_readers/imports.py,sha256=FtNxdPoLeeNycDnl-6rBGxBfYjhQ7VhmI5guj8XKFcU,355
|
|
74
74
|
abstract_utilities/robust_readers/initFuncGen.py,sha256=nrQn1KpSlPNKoOngN1uizVwNMA4llrcd8aGKqlzpXzI,5436
|
|
75
75
|
abstract_utilities/robust_readers/import_utils/__init__.py,sha256=0XaHXUzvgMjSV-4VXcBB-sLcXzL3U3ssHZ95YkvgS9w,195
|
|
76
|
-
abstract_utilities/robust_readers/import_utils/clean_imports.py,sha256=
|
|
76
|
+
abstract_utilities/robust_readers/import_utils/clean_imports.py,sha256=eqnEngnXIp6p4VtePn5BgCzUV2hHF7eVc4M_9Ty61HU,4936
|
|
77
77
|
abstract_utilities/robust_readers/import_utils/dot_utils.py,sha256=pmwnY461mOnDjIjgHD6H9MhQXFaF-q8kWerJDgJ1DuI,2364
|
|
78
78
|
abstract_utilities/robust_readers/import_utils/function_utils.py,sha256=Q9NKvRov3uAaz2Aal3d6fb_opWNXHF9C8GSKOjgfO8Y,1622
|
|
79
79
|
abstract_utilities/robust_readers/import_utils/import_utils.py,sha256=l0GYdtj5FEYX2yknL-8ru7_U2Sp9Hi1NpegqWPLRMc8,11705
|
|
@@ -86,7 +86,7 @@ abstract_utilities/ssh_utils/classes.py,sha256=3Q9BfLpyagNFYyiF4bt-5UCezeUJv9NK9
|
|
|
86
86
|
abstract_utilities/ssh_utils/imports.py,sha256=oX8WAv-pkhizzko_h3fIUp9Vhsse4nR7RN2vwONxIx0,317
|
|
87
87
|
abstract_utilities/ssh_utils/pexpect_utils.py,sha256=JBdOIXBTXAqE5TrsFjmPWJgwSaWyRJN8rbJ6y3_zKPY,10556
|
|
88
88
|
abstract_utilities/ssh_utils/utils.py,sha256=smUWAx3nW1h0etTndJ_te9bkUX5YzQ8kYd9_gD1TXLk,4882
|
|
89
|
-
abstract_utilities-0.2.2.
|
|
90
|
-
abstract_utilities-0.2.2.
|
|
91
|
-
abstract_utilities-0.2.2.
|
|
92
|
-
abstract_utilities-0.2.2.
|
|
89
|
+
abstract_utilities-0.2.2.470.dist-info/METADATA,sha256=STbVjIzK9VpptmvdMNaUuzyIonUTCG3rDkdgqQsMZ58,28108
|
|
90
|
+
abstract_utilities-0.2.2.470.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
91
|
+
abstract_utilities-0.2.2.470.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
|
|
92
|
+
abstract_utilities-0.2.2.470.dist-info/RECORD,,
|
|
File without changes
|
{abstract_utilities-0.2.2.469.dist-info → abstract_utilities-0.2.2.470.dist-info}/top_level.txt
RENAMED
|
File without changes
|