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

@@ -62,205 +62,4 @@ from pprint import pprint
62
62
  # AUTO-EXPORT ALL NON-PRIVATE NAMES
63
63
  # ============================================================
64
64
  __all__ = [name for name in globals() if not name.startswith("_")]
65
- from abstract_utilities import read_from_file,eatAll,inspect, os
66
- import_tag = 'import '
67
- from_tag = 'from '
68
- def get_caller_path(i=None):
69
- i = i or 1
70
- frame = inspect.stack()[i]
71
- return os.path.abspath(frame.filename)
72
- def make_list(obj:any) -> list:
73
- """
74
- Converts the input object to a list. If the object is already a list, it is returned as is.
75
-
76
- Args:
77
- obj: The object to convert.
78
-
79
- Returns:
80
- list: The object as a list.
81
- """
82
- if isinstance(obj,str):
83
- if ',' in obj:
84
- obj = obj.split(',')
85
- if isinstance(obj,set) or isinstance(obj,tuple):
86
- return list(obj)
87
- if isinstance(obj, list):
88
- return obj
89
- return [obj]
90
- def getAlphas(lower=True,capitalize=False,listObj=False):
91
- obj = ''
92
- alphas = 'abcdefghijklmoprstuvwxyz'
93
- if lower:
94
- obj+=alphas
95
- if capitalize:
96
- obj+=alphas.upper()
97
- if listObj:
98
- obj = list(obj)
99
- return obj
100
- def getInts(string=False,listObj=False):
101
- obj=12345678909
102
- if string:
103
- obj = str(obj)
104
- if listObj:
105
- obj = list(obj)
106
- return obj
107
- def get_alpha_ints(ints=True,alpha=True,lower=True,capitalize=True,string=True,listObj=True):
108
- objs = [] if listObj else ""
109
- if ints:
110
- objs+=getInts(string=string,listObj=listObj)
111
- if alpha:
112
- objs+=getAlphas(lower=lower,capitalize=capitalize,listObj=listObj)
113
- return objs
114
- def eatElse(
115
- stringObj,
116
- chars=None,
117
- ints=True,
118
- alpha=True,
119
- lower=True,
120
- capitalize=True,
121
- string=True,
122
- listObj=True
123
- ):
124
- alpha_ints = get_alpha_ints(
125
- ints=True,
126
- alpha=True,
127
- lower=True,
128
- capitalize=True,
129
- string=True,
130
- listObj=True
131
- )
132
- chars = make_list(chars or [])+alpha_ints
133
65
 
134
- while True:
135
- if stringObj:
136
- str_0 = stringObj[0] not in chars
137
- str_1 = stringObj[-1] not in chars
138
- str_eat = str_0 or str_1
139
- if not str_eat:
140
- return stringObj
141
- if stringObj and str_0:
142
- stringObj = stringObj[1:] if len(stringObj) !=1 else ""
143
- if stringObj and str_1:
144
- stringObj = stringObj[:-1] if len(stringObj) !=1 else ""
145
- else:
146
- return stringObj
147
- def clean_line(line):
148
- return eatAll(line,[' ','','\t','\n'])
149
- def is_line_import(line):
150
- if line and (line.startswith(from_tag) or line.startswith(import_tag)):
151
- return True
152
- return False
153
- def is_line_group_import(line):
154
- if line and (line.startswith(from_tag) and import_tag in line):
155
- return True
156
- return False
157
- def get_import_pkg(line):
158
- if is_line_group_import(line):
159
-
160
- return clean_line(line.split(from_tag)[1].split(import_tag)[0])
161
- def get_imports_from_import_pkg(line):
162
- if is_line_group_import(line):
163
- return get_cleaned_import_list(line,commaClean=True)
164
- def add_imports_to_import_pkg_js(import_pkg,imports,import_pkg_js=None):
165
- import_pkg_js = import_pkg_js or {}
166
- imports = clean_imports(imports)
167
- if import_pkg not in import_pkg_js:
168
- i = len(import_pkg_js["nulines"])
169
- import_pkg_js[import_pkg]={"imports":imports,"line":i}
170
- import_line = f"from {import_pkg} import "
171
- if import_pkg == "import":
172
- import_line = import_tag
173
- import_pkg_js["nulines"].append(import_line)
174
- else:
175
- import_pkg_js[import_pkg]["imports"]+=imports
176
- return import_pkg_js
177
- def update_import_pkg_js(line,import_pkg_js=None):
178
- import_pkg_js = import_pkg_js or {}
179
- if is_line_group_import(line):
180
- import_pkg = get_import_pkg(line)
181
- imports = get_imports_from_import_pkg(line)
182
- import_pkg_js = add_imports_to_import_pkg_js(import_pkg,imports,import_pkg_js=import_pkg_js)
183
- else:
184
- if len(import_pkg_js["nulines"]) >0 and line == '' and is_line_import(import_pkg_js["nulines"][-1]):
185
- pass
186
- else:
187
- import_pkg_js["nulines"].append(line)
188
- return import_pkg_js
189
- def is_from_line_group(line):
190
- if line and line.startswith(from_tag) and import_tag in line and '(' in line:
191
- import_spl = line.split(import_tag)[-1]
192
- import_spl_clean = clean_line(line)
193
- if not import_spl_clean.endswith(')'):
194
- return True
195
- return False
196
- def clean_imports(imports,commaClean=True):
197
- chars=["*"]
198
- if not commaClean:
199
- chars.append(',')
200
- if isinstance(imports,str):
201
- imports = imports.split(',')
202
- return [eatElse(imp,chars=chars) for imp in imports if imp]
203
- def get_cleaned_import_list(line,commaClean=True):
204
- cleaned_import_list=[]
205
- if import_tag in line:
206
- imports = line.split(import_tag)[1]
207
- cleaned_import_list+=clean_imports(imports,commaClean=commaClean)
208
- return cleaned_import_list
209
- def combine_lone_imports(text=None,file_path=None,write=False):
210
- text = text or ''
211
- imports_js = {}
212
- if file_path and os.path.isfile(file_path):
213
- text+=read_from_file(file_path)
214
- lines = text.split('\n')
215
- cleaned_import_list=[]
216
- nu_lines = []
217
- j=None
218
- is_from_group = False
219
- import_pkg_js={"nulines":[]}
220
- for line in lines:
221
- if line.startswith(import_tag) and ' from ' not in line:
222
- cleaned_import_list = get_cleaned_import_list(line)
223
- import_pkg_js = add_imports_to_import_pkg_js("import",cleaned_import_list,import_pkg_js=import_pkg_js)
224
- else:
225
- if is_from_group:
226
- import_pkg=is_from_group
227
- line = clean_line(line)
228
- if line.endswith(')'):
229
- is_from_group=False
230
- line=line[:-1]
231
- imports_from_import_pkg = clean_imports(line)
232
- import_pkg_js = add_imports_to_import_pkg_js(import_pkg,imports_from_import_pkg,import_pkg_js=import_pkg_js)
233
-
234
- else:
235
- import_pkg_js=update_import_pkg_js(line,import_pkg_js=import_pkg_js)
236
- if is_from_line_group(line) and is_from_group == False:
237
-
238
- is_from_group=get_import_pkg(line)
239
- nu_lines = import_pkg_js["nulines"]
240
- for pkg,values in import_pkg_js.items():
241
- comments = []
242
- if pkg != "nulines":
243
- line = values.get('line')
244
- imports = values.get('imports')
245
- for i,imp in enumerate(imports):
246
- if '#' in imp:
247
- imp_spl = imp.split('#')
248
- comments.append(imp_spl[-1])
249
- imports[i] = clean_line(imp_spl[0])
250
- imports = list(set(imports))
251
- if '*' in imports:
252
- imports="*"
253
- else:
254
- imports=','.join(imports)
255
- if comments:
256
- comments=','.join(comments)
257
- imports+=f" #{comments}"
258
-
259
- nu_lines[line] += imports
260
- contents = '\n'.join(nu_lines)
261
- if file_path and write:
262
- write_to_file(contents=contents,file_path=file_path)
263
- return contents
264
- abs_path = get_caller_path()
265
- nu_contents = combine_lone_imports(file_path=abs_path)
266
- input(nu_contents)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstract_utilities
3
- Version: 0.2.2.468
3
+ Version: 0.2.2.469
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
@@ -61,7 +61,7 @@ abstract_utilities/file_utils/imports/classes.py,sha256=zw16D_h5AxJiks4ydbqkWkXV
61
61
  abstract_utilities/file_utils/imports/clean_imps.py,sha256=DB_NEKR8YLla5qCkTMuNscMoTnipEm3nCWnaH8wqQDc,5287
62
62
  abstract_utilities/file_utils/imports/constants.py,sha256=eIeSj48vtfa8CTYKuuZXbgJQepBrMracfVguaSuN41U,1626
63
63
  abstract_utilities/file_utils/imports/file_functions.py,sha256=brQha7TV9DaJe-hZSuHoFZBUI_45hxrGOIBTAojPWU8,297
64
- abstract_utilities/file_utils/imports/imports.py,sha256=xsxfaNE7uvdJH8WKUMk1RNTq8CpIC6adAwno96Dmvuc,9147
64
+ abstract_utilities/file_utils/imports/imports.py,sha256=eDvLMtTQlExI1z7ddnPYoXWyrYtp48JuiAzBPqL5wWA,2057
65
65
  abstract_utilities/file_utils/imports/module_imports.py,sha256=BROjglIl217zEuU0kwRilkK9vLrYC9e44AS5HS8HwD0,513
66
66
  abstract_utilities/robust_reader/__init__.py,sha256=4i6qW4lwhdYuoO5-p9Xbt8Lpmr3hzCh9Rgb9y19QJwk,28
67
67
  abstract_utilities/robust_reader/file_reader2.py,sha256=U-5opkLu-bct091Eb-5CiNBTf0UFoSITYi8zR-Sz38w,25077
@@ -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.468.dist-info/METADATA,sha256=9hAVfrsbxq20y58SW5cZC5ORLn4tvmi0-KB59Y2al50,28108
90
- abstract_utilities-0.2.2.468.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
- abstract_utilities-0.2.2.468.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
92
- abstract_utilities-0.2.2.468.dist-info/RECORD,,
89
+ abstract_utilities-0.2.2.469.dist-info/METADATA,sha256=Is22Ze7s9N2iV4DlsHnheuKkwPUVPN0RAzbmkdaqQrA,28108
90
+ abstract_utilities-0.2.2.469.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ abstract_utilities-0.2.2.469.dist-info/top_level.txt,sha256=BF0GZ0xVFfN1K-hFIWPO3viNsOs1sSF86n1vHBg39FM,19
92
+ abstract_utilities-0.2.2.469.dist-info/RECORD,,