ParUtils 1.2.6__py3-none-any.whl → 1.2.8__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.
- parutils/__init__.py +3 -2
- parutils/changelog.py +9 -3
- parutils/file.py +6 -2
- parutils/strg.py +1 -1
- parutils/{testing.py → te.py} +7 -0
- parutils/tests/logging/test_logging.py +2 -2
- parutils/tests/test_msc.py +15 -2
- {parutils-1.2.6.dist-info → parutils-1.2.8.dist-info}/METADATA +1 -1
- {parutils-1.2.6.dist-info → parutils-1.2.8.dist-info}/RECORD +12 -12
- {parutils-1.2.6.dist-info → parutils-1.2.8.dist-info}/WHEEL +0 -0
- {parutils-1.2.6.dist-info → parutils-1.2.8.dist-info}/licenses/LICENSE +0 -0
- {parutils-1.2.6.dist-info → parutils-1.2.8.dist-info}/top_level.txt +0 -0
parutils/__init__.py
CHANGED
parutils/changelog.py
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
__VERSION__ = '1.2.
|
2
|
-
#
|
3
|
-
|
1
|
+
__VERSION__ = '1.2.8'
|
2
|
+
# try_bool
|
3
|
+
|
4
|
+
# __VERSION__ = '1.2.7'
|
5
|
+
# # file.load_txt - clean_lst
|
6
|
+
|
7
|
+
# __VERSION__ = '1.2.6'
|
8
|
+
# # Wtry context manager
|
9
|
+
# # truncate middle by default
|
4
10
|
|
5
11
|
# __VERSION__ = '1.2.5'
|
6
12
|
# # Faster file.load_txt
|
parutils/file.py
CHANGED
@@ -63,17 +63,21 @@ def list_files(in_dir,
|
|
63
63
|
return out
|
64
64
|
|
65
65
|
|
66
|
-
def load_txt(in_path, list_out=True):
|
66
|
+
def load_txt(in_path, list_out=True, clean_lst=True):
|
67
67
|
"""Loads a text file
|
68
68
|
|
69
69
|
- list_out: if True, a list is output, each element representing a line of the file. If False, a string is output.
|
70
|
+
- clean_lst: if True, the last element of the output list is deleted when void.
|
70
71
|
"""
|
71
72
|
|
72
73
|
with open(in_path, 'r', encoding='utf-8') as f:
|
73
74
|
data = f.read()
|
74
75
|
|
75
76
|
if list_out:
|
76
|
-
|
77
|
+
out = data.split('\n')
|
78
|
+
if out and clean_lst and out[-1] == '':
|
79
|
+
del out[-1]
|
80
|
+
return out
|
77
81
|
else:
|
78
82
|
return data
|
79
83
|
|
parutils/strg.py
CHANGED
@@ -78,7 +78,7 @@ def hash512(in_str: str, length=10):
|
|
78
78
|
always outputs the same string for the same input string"""
|
79
79
|
import hashlib
|
80
80
|
|
81
|
-
out = hashlib.sha512(in_str.encode('utf-8')).hexdigest()[:length]
|
81
|
+
out = hashlib.sha512(str(in_str).encode('utf-8')).hexdigest()[:length]
|
82
82
|
return out
|
83
83
|
|
84
84
|
|
parutils/{testing.py → te.py}
RENAMED
@@ -25,11 +25,11 @@ def t_log_every():
|
|
25
25
|
|
26
26
|
log_path = u.get_logger().log_path
|
27
27
|
logs = u.load_txt(log_path)
|
28
|
-
assert len(logs) ==
|
28
|
+
assert len(logs) == 13
|
29
29
|
logs0 = u.close_logger().logs
|
30
30
|
assert "log_elt_5" in logs0[2]
|
31
31
|
logs = u.load_txt(log_path)
|
32
|
-
assert len(logs) ==
|
32
|
+
assert len(logs) == 16
|
33
33
|
logs_txt = u.load_txt(log_path, False)
|
34
34
|
assert "log_elt_5" in logs_txt
|
35
35
|
assert len(u.g.logs) == 3
|
parutils/tests/test_msc.py
CHANGED
@@ -2,6 +2,15 @@ import parutils as u
|
|
2
2
|
|
3
3
|
|
4
4
|
def test_msc():
|
5
|
+
|
6
|
+
res = u.try_bool(ok_func, 'arg1', 'arg2', kwarg1='val1', kwarg2='val2')
|
7
|
+
assert res[0]
|
8
|
+
assert res[1] == "ok: ('arg1', 'arg2'), {'kwarg1': 'val1', 'kwarg2': 'val2'}"
|
9
|
+
|
10
|
+
res = u.try_bool(nok_func_args, 'arg1', 'arg2', kwarg1='val1', kwarg2='val2')
|
11
|
+
assert not res[0]
|
12
|
+
assert str(res[1]) == "test_error: ('arg1', 'arg2'), {'kwarg1': 'val1', 'kwarg2': 'val2'}"
|
13
|
+
|
5
14
|
lst = ['key1=value1', 'key2=value2']
|
6
15
|
out = u.list_to_dict(lst)
|
7
16
|
|
@@ -31,8 +40,12 @@ def nok_func():
|
|
31
40
|
raise Exception('test_error')
|
32
41
|
|
33
42
|
|
34
|
-
def
|
35
|
-
|
43
|
+
def nok_func_args(*args, **kwargs):
|
44
|
+
raise Exception(f'test_error: {args}, {kwargs}')
|
45
|
+
|
46
|
+
|
47
|
+
def ok_func(*args, **kwargs):
|
48
|
+
return f'ok: {args}, {kwargs}'
|
36
49
|
|
37
50
|
|
38
51
|
if __name__ == '__main__': # pragma: no cover
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ParUtils
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.8
|
4
4
|
Summary: This package contains a bunch of Python utilities developed for Support, Test and Automation IT Engineers
|
5
5
|
Author-email: Paul ARNAUD <paularnaud2@gmail.com>
|
6
6
|
Project-URL: Homepage, https://github.com/paularnaud2/ParUtils
|
@@ -1,12 +1,12 @@
|
|
1
|
-
parutils/__init__.py,sha256
|
2
|
-
parutils/changelog.py,sha256=
|
1
|
+
parutils/__init__.py,sha256=vC7wsFBrPkFXar4gRk06FVGPVPUL8nOU9WfjuyuoNUQ,1477
|
2
|
+
parutils/changelog.py,sha256=CFQM8ci_B1RqwMHp9BOxD9g3mER2qS7JWz-Fq1TPmO0,2127
|
3
3
|
parutils/csvl.py,sha256=JgJPnN8IPrdMD8OOlPtDSEhJULMkPkqnDnB-D4z9F-E,2871
|
4
4
|
parutils/dq.py,sha256=kdvzOo5FLCumXagY05kGSseYlbR-zvjjmsMtGVliVc8,2302
|
5
|
-
parutils/file.py,sha256
|
5
|
+
parutils/file.py,sha256=-oDnjMqIxL0jyMWOU5LRDnPcoXl5S9VEMp0xiLHcZ9w,2933
|
6
6
|
parutils/g.py,sha256=n99gQbLs2rmszBYw_wy43P4iQo3lqpBHz3-Q7sm9n_U,11
|
7
7
|
parutils/msc.py,sha256=6Yx-VJss0xRqQAiuVURu0L4oDHkcsF7T5EK6eXrm9TQ,745
|
8
|
-
parutils/strg.py,sha256=
|
9
|
-
parutils/
|
8
|
+
parutils/strg.py,sha256=iBlPWeBupZ556KjuYM_ubb8v7Tjd46KN4sjVW9tzXao,5884
|
9
|
+
parutils/te.py,sha256=At5TUG78w7qgnd0T2heu1HL6PH4fPQkXWDcwx6VtGig,1376
|
10
10
|
parutils/wrap.py,sha256=PqMyKodgEjWDXoIVZZXRaBSdkGFL5OWmVJttl2Crrg8,421
|
11
11
|
parutils/logging/__init__.py,sha256=rSNpgjuYer-Hhn6zKzKwKSn_KfcajEXlk6cJnPC9eJU,461
|
12
12
|
parutils/logging/cl.py,sha256=NCLuxLHvqRTypZlAgwnegkByLTnTirKntnwguJHBelA,2086
|
@@ -20,13 +20,13 @@ parutils/tests/conftest.py,sha256=iIyQvgVV8GzUwJ0tlN2KUJHX5ZO7lp8bKFK3VmRx4DU,48
|
|
20
20
|
parutils/tests/test_csv.py,sha256=vHs_CT1oLWAGkRvKdF-Ilz62MczEDKqQfmmQe-nt-Wg,671
|
21
21
|
parutils/tests/test_dq.py,sha256=Qb5lldyg-UAOvNbViNLnchkG93v_-DQ96XkIPgOIXWo,967
|
22
22
|
parutils/tests/test_file.py,sha256=iYaSm0YU7qQIq9p7Sea4KPdoKRpqWcbgbkZG4u0DR_s,1031
|
23
|
-
parutils/tests/test_msc.py,sha256=
|
23
|
+
parutils/tests/test_msc.py,sha256=XLImwN-GS1qCBABgCxs2ZY9QGbtmNhul-tIZqiWUL0Q,1559
|
24
24
|
parutils/tests/logging/check_log.py,sha256=Se-EuWuwxlcksjIkLZU4d77-o3eyFdppJCxGJ-GcorY,2332
|
25
|
-
parutils/tests/logging/test_logging.py,sha256=
|
25
|
+
parutils/tests/logging/test_logging.py,sha256=C5lciMZkRi1LL0J6r_KIK2cwld3LmKKA413eZXEd3rI,5259
|
26
26
|
parutils/tests/string/check_log.py,sha256=m2RRJIorA6jg7uV_8nxWfKHUFZ98YPDn-DqzcTw3cQ0,211
|
27
27
|
parutils/tests/string/test_string.py,sha256=9709GQ8iw4MnRHgBuGK9Ed_uuk9rL8EDVXdK0_la9zQ,2140
|
28
|
-
parutils-1.2.
|
29
|
-
parutils-1.2.
|
30
|
-
parutils-1.2.
|
31
|
-
parutils-1.2.
|
32
|
-
parutils-1.2.
|
28
|
+
parutils-1.2.8.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
29
|
+
parutils-1.2.8.dist-info/METADATA,sha256=JpAuN7VpbgHrTic7pawQbAD5JYtWB1eYPFMGpREg88Q,6868
|
30
|
+
parutils-1.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
31
|
+
parutils-1.2.8.dist-info/top_level.txt,sha256=1MDobUcroeYEvdupZCAFvA5hJjm7LSDUV5A4jHySNis,9
|
32
|
+
parutils-1.2.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|