encommon 0.8.2__py3-none-any.whl → 0.10.0__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.
- encommon/config/config.py +11 -1
- encommon/config/params.py +3 -3
- encommon/config/test/test_config.py +14 -6
- encommon/config/test/test_files.py +14 -8
- encommon/config/test/test_logger.py +14 -8
- encommon/config/test/test_paths.py +14 -8
- encommon/conftest.py +2 -3
- encommon/crypts/params.py +1 -1
- encommon/crypts/test/test_crypts.py +8 -4
- encommon/crypts/test/test_hashes.py +8 -4
- encommon/times/test/test_duration.py +4 -2
- encommon/times/test/test_timers.py +8 -4
- encommon/times/test/test_times.py +8 -4
- encommon/times/test/test_window.py +8 -4
- encommon/types/__init__.py +12 -0
- encommon/types/notate.py +321 -0
- encommon/types/strings.py +75 -0
- encommon/types/test/__init__.py +37 -0
- encommon/types/test/test_dicts.py +23 -28
- encommon/types/test/test_notate.py +217 -0
- encommon/types/test/test_strings.py +42 -0
- encommon/version.txt +1 -1
- {encommon-0.8.2.dist-info → encommon-0.10.0.dist-info}/METADATA +1 -1
- {encommon-0.8.2.dist-info → encommon-0.10.0.dist-info}/RECORD +27 -25
- {encommon-0.8.2.dist-info → encommon-0.10.0.dist-info}/LICENSE +0 -0
- {encommon-0.8.2.dist-info → encommon-0.10.0.dist-info}/WHEEL +0 -0
- {encommon-0.8.2.dist-info → encommon-0.10.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,217 @@
|
|
1
|
+
"""
|
2
|
+
Functions and routines associated with Enasis Network Common Library.
|
3
|
+
|
4
|
+
This file is part of Enasis Network software eco-system. Distribution
|
5
|
+
is permitted, for more information consult the project license file.
|
6
|
+
"""
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
from copy import deepcopy
|
11
|
+
|
12
|
+
from _pytest.python_api import RaisesContext
|
13
|
+
|
14
|
+
from pytest import raises
|
15
|
+
|
16
|
+
from . import _DICT1R
|
17
|
+
from ..notate import delate
|
18
|
+
from ..notate import getate
|
19
|
+
from ..notate import setate
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def test_getate() -> None:
|
24
|
+
"""
|
25
|
+
Perform various tests associated with relevant routines.
|
26
|
+
"""
|
27
|
+
|
28
|
+
source = deepcopy(_DICT1R)
|
29
|
+
|
30
|
+
|
31
|
+
value = getate(['1', 2], '1')
|
32
|
+
assert value == 2
|
33
|
+
|
34
|
+
value = getate((1, 2), '1')
|
35
|
+
assert value == 2
|
36
|
+
|
37
|
+
value = getate({'1': 2}, '1')
|
38
|
+
assert value == 2
|
39
|
+
|
40
|
+
|
41
|
+
path = 'recurse/dict/key'
|
42
|
+
value = getate(source, path)
|
43
|
+
|
44
|
+
assert value == 'd1dict'
|
45
|
+
|
46
|
+
|
47
|
+
path = 'recurse/list/0'
|
48
|
+
value = getate(source, path)
|
49
|
+
|
50
|
+
assert value == 'd1list'
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
def test_getate_cover() -> None:
|
55
|
+
"""
|
56
|
+
Perform various tests associated with relevant routines.
|
57
|
+
"""
|
58
|
+
|
59
|
+
source = deepcopy(_DICT1R)
|
60
|
+
|
61
|
+
|
62
|
+
assert not getate({}, 'd/n/e')
|
63
|
+
assert not getate([], '0/n/e')
|
64
|
+
|
65
|
+
|
66
|
+
path = 'recurse/str/a'
|
67
|
+
value = getate(source, path)
|
68
|
+
|
69
|
+
assert value is None
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
def test_setate() -> None:
|
74
|
+
"""
|
75
|
+
Perform various tests associated with relevant routines.
|
76
|
+
"""
|
77
|
+
|
78
|
+
source = deepcopy(_DICT1R)
|
79
|
+
|
80
|
+
|
81
|
+
path = 'list/1'
|
82
|
+
before = getate(source, path)
|
83
|
+
setate(source, path, 1)
|
84
|
+
after = getate(source, path)
|
85
|
+
assert after == 1
|
86
|
+
assert before is None
|
87
|
+
|
88
|
+
|
89
|
+
path = 'recurse/dict/key'
|
90
|
+
before = getate(source, path)
|
91
|
+
setate(source, path, 1)
|
92
|
+
after = getate(source, path)
|
93
|
+
assert after == 1
|
94
|
+
assert before == 'd1dict'
|
95
|
+
|
96
|
+
|
97
|
+
path = 'nested/0/dict/key'
|
98
|
+
before = getate(source, path)
|
99
|
+
setate(source, path, 1)
|
100
|
+
after = getate(source, path)
|
101
|
+
assert after == 1
|
102
|
+
assert before == 'd1dict'
|
103
|
+
|
104
|
+
|
105
|
+
path = 'recurse/list/0'
|
106
|
+
before = getate(source, path)
|
107
|
+
setate(source, path, 1)
|
108
|
+
after = getate(source, path)
|
109
|
+
assert after == 1
|
110
|
+
assert before == 'd1list'
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
def test_setate_cover() -> None:
|
115
|
+
"""
|
116
|
+
Perform various tests associated with relevant routines.
|
117
|
+
"""
|
118
|
+
|
119
|
+
source = deepcopy(_DICT1R)
|
120
|
+
|
121
|
+
|
122
|
+
path = 'nested/1/dict/key'
|
123
|
+
before = getate(source, path)
|
124
|
+
setate(source, path, 1)
|
125
|
+
after = getate(source, path)
|
126
|
+
assert after == 1
|
127
|
+
assert before is None
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
def test_setate_raises() -> None:
|
132
|
+
"""
|
133
|
+
Perform various tests associated with relevant routines.
|
134
|
+
"""
|
135
|
+
|
136
|
+
_raises: RaisesContext[
|
137
|
+
ValueError | IndexError]
|
138
|
+
|
139
|
+
|
140
|
+
_raises = raises(ValueError)
|
141
|
+
|
142
|
+
with _raises as reason:
|
143
|
+
setate(1, '1', 1) # type: ignore
|
144
|
+
|
145
|
+
_reason = str(reason.value)
|
146
|
+
|
147
|
+
assert _reason == 'source'
|
148
|
+
|
149
|
+
|
150
|
+
_raises = raises(IndexError)
|
151
|
+
|
152
|
+
with _raises as reason:
|
153
|
+
setate([], '1', 1)
|
154
|
+
|
155
|
+
_reason = str(reason.value)
|
156
|
+
|
157
|
+
assert _reason == '1'
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
def test_delate() -> None:
|
162
|
+
"""
|
163
|
+
Perform various tests associated with relevant routines.
|
164
|
+
"""
|
165
|
+
|
166
|
+
source = deepcopy(_DICT1R)
|
167
|
+
|
168
|
+
|
169
|
+
path = 'recurse/dict/key'
|
170
|
+
before = getate(source, path)
|
171
|
+
delate(source, path)
|
172
|
+
after = getate(source, path)
|
173
|
+
assert after is None
|
174
|
+
assert before == 'd1dict'
|
175
|
+
|
176
|
+
|
177
|
+
path = 'nested/0/dict/key'
|
178
|
+
before = getate(source, path)
|
179
|
+
delate(source, path)
|
180
|
+
after = getate(source, path)
|
181
|
+
assert after is None
|
182
|
+
assert before == 'd1dict'
|
183
|
+
|
184
|
+
|
185
|
+
path = 'recurse/list/0'
|
186
|
+
before = getate(source, path)
|
187
|
+
delate(source, path)
|
188
|
+
after = getate(source, path)
|
189
|
+
assert after is None
|
190
|
+
assert before == 'd1list'
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
def test_delate_raises() -> None:
|
195
|
+
"""
|
196
|
+
Perform various tests associated with relevant routines.
|
197
|
+
"""
|
198
|
+
|
199
|
+
|
200
|
+
_raises = raises(ValueError)
|
201
|
+
|
202
|
+
with _raises as reason:
|
203
|
+
delate(1, '1') # type: ignore
|
204
|
+
|
205
|
+
_reason = str(reason.value)
|
206
|
+
|
207
|
+
assert _reason == 'source'
|
208
|
+
|
209
|
+
|
210
|
+
_raises = raises(ValueError)
|
211
|
+
|
212
|
+
with _raises as reason:
|
213
|
+
delate({'a': 1}, 'a/1/c')
|
214
|
+
|
215
|
+
_reason = str(reason.value)
|
216
|
+
|
217
|
+
assert _reason == 'source'
|
@@ -7,6 +7,9 @@ is permitted, for more information consult the project license file.
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
+
from ..strings import hasstr
|
11
|
+
from ..strings import inrepr
|
12
|
+
from ..strings import instr
|
10
13
|
from ..strings import striplower
|
11
14
|
|
12
15
|
|
@@ -17,3 +20,42 @@ def test_striplower() -> None:
|
|
17
20
|
"""
|
18
21
|
|
19
22
|
assert striplower(' Foo ') == 'foo'
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
def test_hasstr() -> None:
|
27
|
+
"""
|
28
|
+
Perform various tests associated with relevant routines.
|
29
|
+
"""
|
30
|
+
|
31
|
+
assert hasstr('abc', 'a')
|
32
|
+
assert hasstr('abc', 'b')
|
33
|
+
assert hasstr('abc', 'c')
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
def test_inrepr() -> None:
|
38
|
+
"""
|
39
|
+
Perform various tests associated with relevant routines.
|
40
|
+
"""
|
41
|
+
|
42
|
+
class MyClass:
|
43
|
+
pass
|
44
|
+
|
45
|
+
item = MyClass()
|
46
|
+
|
47
|
+
assert inrepr('MyClass', item)
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def test_instr() -> None:
|
52
|
+
"""
|
53
|
+
Perform various tests associated with relevant routines.
|
54
|
+
"""
|
55
|
+
|
56
|
+
class MyClass:
|
57
|
+
pass
|
58
|
+
|
59
|
+
item = MyClass()
|
60
|
+
|
61
|
+
assert instr('MyClass', item)
|
encommon/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
@@ -1,27 +1,27 @@
|
|
1
1
|
encommon/__init__.py,sha256=VoXUcphq-gcXCraaU47EtXBftF6UVuQPMGr0fuCTt9A,525
|
2
|
-
encommon/conftest.py,sha256=
|
2
|
+
encommon/conftest.py,sha256=Bu-KoRxxWu0Gwd8uEhBm0SbGaxwc9mzq7fZUa_igi80,1797
|
3
3
|
encommon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
encommon/version.txt,sha256=
|
4
|
+
encommon/version.txt,sha256=3CT-tb01CE2K4ypOr77BI1JwfUZiQB_LzJu9aWzed6k,7
|
5
5
|
encommon/config/__init__.py,sha256=i0G48SrSk_QgZ-xOMYtsllPT2Y06i7j29XEkqUH0wZ8,859
|
6
6
|
encommon/config/common.py,sha256=QGrbA3OlQ0nta6cOyEu0dw8li9UlV_J7Yn3rhZLm7mw,2099
|
7
|
-
encommon/config/config.py,sha256=
|
7
|
+
encommon/config/config.py,sha256=TZIUqyIRQfVWLUKsgGVH0coHp9dU-GAXFROdwSsoNvQ,5010
|
8
8
|
encommon/config/files.py,sha256=Mdb9MN4AKzue6Mdl4B2C8epiuPI6vnfVu55yiPUTiQ8,2388
|
9
9
|
encommon/config/logger.py,sha256=5X7Y72g-D4hJ2TCfqDxiAZpQcUT-Exgbf2t7kiIM0q0,13488
|
10
|
-
encommon/config/params.py,sha256=
|
10
|
+
encommon/config/params.py,sha256=6hg0aiUnG5alPv3Kxd4kR_9OXOMLJzuvjXjhuYpyTMU,1800
|
11
11
|
encommon/config/paths.py,sha256=eR0BQC_TaKHu1dQGrC8o69l6dEqDoI8JS9IHmPrsJ68,2535
|
12
12
|
encommon/config/test/__init__.py,sha256=i0JAeRcM-0YH2StGfwpaDbZV9dVribNSgFDcYcPPay8,313
|
13
13
|
encommon/config/test/test_common.py,sha256=K9KiAfbMBXaoYErW10X1AigFs8wNNNOxKG8QV6IYJdA,1069
|
14
|
-
encommon/config/test/test_config.py,sha256=
|
15
|
-
encommon/config/test/test_files.py,sha256=
|
16
|
-
encommon/config/test/test_logger.py,sha256=
|
17
|
-
encommon/config/test/test_paths.py,sha256=
|
14
|
+
encommon/config/test/test_config.py,sha256=POup-M0oIuCSceUDV1tkSCmv0bwKQS_wgFzesUgIgNM,2440
|
15
|
+
encommon/config/test/test_files.py,sha256=qJgavSxTxilHOnGzfF6fBpViOmKFGcBdupOIRhDsXuk,2295
|
16
|
+
encommon/config/test/test_logger.py,sha256=uzun7HFk5XgiuEvq-50nJtQ_poJbu8BxvsJjeOOFzqk,5188
|
17
|
+
encommon/config/test/test_paths.py,sha256=jCrSEnPkZprsJSvolsfTKoyuYqxqyQdDymL9yk3elvQ,2633
|
18
18
|
encommon/crypts/__init__.py,sha256=UsGEitz8rWa7DQF3iAxEbTUAbdiEnE87LSuRs4OBeAQ,371
|
19
19
|
encommon/crypts/crypts.py,sha256=fCYEOlq5vp34L9yPT-oMhvI-8o6FRoPViM7aZShB1_Y,3540
|
20
20
|
encommon/crypts/hashes.py,sha256=bpQf2-Ma5SdMaEWP2nL1_9rtEQmTE0XTdDvSD-fQ9Mk,3075
|
21
|
-
encommon/crypts/params.py,sha256=
|
21
|
+
encommon/crypts/params.py,sha256=TAowPtCVse1BysBMZ70LFvtaChAQmoBo4E_MHZ2fpSs,588
|
22
22
|
encommon/crypts/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
|
23
|
-
encommon/crypts/test/test_crypts.py,sha256=
|
24
|
-
encommon/crypts/test/test_hashes.py,sha256=
|
23
|
+
encommon/crypts/test/test_crypts.py,sha256=MnMZPGWSN-vV3iA1s4OsZ72dqHII1a244fSPDILXfVE,2706
|
24
|
+
encommon/crypts/test/test_hashes.py,sha256=JYpPit7ISv6u-5-HbC3wSCxuieySDLKawgnE7-xHgTY,1180
|
25
25
|
encommon/times/__init__.py,sha256=Gyi34zy6po35P2sNvbwnsOQg4kU6KOodfygLhRdCEgU,638
|
26
26
|
encommon/times/common.py,sha256=T-Bt8P1EBn-TOEF0Bd0kUJMr6qEFCnHOLiYqgJE9mqk,3635
|
27
27
|
encommon/times/duration.py,sha256=LTROiKcRXvPcs2Gz9KaB5Cmxo9NXd3TcMo5-jnTxPo0,10794
|
@@ -31,19 +31,21 @@ encommon/times/times.py,sha256=xuPtFR2Gkr_AFPfspqGq3cU67rfZr0xvKcQvlw2Q-xQ,9696
|
|
31
31
|
encommon/times/window.py,sha256=CA9zIdi0ad-WiC03zG_T_WilWoEwATISVBOF1Jqtf4o,7975
|
32
32
|
encommon/times/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
|
33
33
|
encommon/times/test/test_common.py,sha256=r0vwJ-2SiwVOvSyEB0JkpWfsAeLvSCEhuLaYE1rk0VY,2059
|
34
|
-
encommon/times/test/test_duration.py,sha256=
|
34
|
+
encommon/times/test/test_duration.py,sha256=ofCBdQ4-tOKP5W5U2xyTaZrCVvD-dWEgnYoCvZ99MuA,4189
|
35
35
|
encommon/times/test/test_parse.py,sha256=iIKanoqqQMxpXVxo9HNwY7oscQB1HzXU9QId0puoGd4,4055
|
36
|
-
encommon/times/test/test_timers.py,sha256=
|
37
|
-
encommon/times/test/test_times.py,sha256=
|
38
|
-
encommon/times/test/test_window.py,sha256=
|
39
|
-
encommon/types/__init__.py,sha256=
|
36
|
+
encommon/times/test/test_timers.py,sha256=bOfajUjnpZJItTvs1UOWuZxWT-HGI6oyi3svA8ZFYhg,3128
|
37
|
+
encommon/times/test/test_times.py,sha256=vxEtXI9gYFlWnBLsyPyi17a96MJzgcI79SCy8U1Co8I,1748
|
38
|
+
encommon/times/test/test_window.py,sha256=Px6Qfg_uVp34TLV-OiOJ2rJU1vCqqTFKeme2CceCoZQ,5464
|
39
|
+
encommon/types/__init__.py,sha256=L1pdigJyPNPEoAkkbCHM9IhmFtU2GjFRxHMRTAnPqKk,667
|
40
40
|
encommon/types/dicts.py,sha256=lC2FmPzMEj9L73jUjf3o6OVQ-LqK_3gp5nBwYibdGfo,2265
|
41
41
|
encommon/types/empty.py,sha256=n5y5maXkcM3xNYNYGK6iqvk98ivQSeguaedwc0HoMv4,2739
|
42
|
-
encommon/types/
|
43
|
-
encommon/types/
|
44
|
-
encommon/types/test/
|
42
|
+
encommon/types/notate.py,sha256=odlc0fblAEnfPlGqJJSvNTYtXvD0jP7kOYUiFnea6YE,6550
|
43
|
+
encommon/types/strings.py,sha256=oFPRrJuK3ey5FHeHoUTPoinpYlwuJmcbi0UQjRupEM4,2175
|
44
|
+
encommon/types/test/__init__.py,sha256=UIyNazTlIIdUzQS0brlD7hCPN_LYw_J6Ucxm8wh3cPU,789
|
45
|
+
encommon/types/test/test_dicts.py,sha256=-RLkcyexCXGSyJyPx1e3QU8sNXEgtSvD9pZakdOwVvg,2702
|
45
46
|
encommon/types/test/test_empty.py,sha256=4GiBs3xulfTnJ5xuGm2hM_PRcHspYEj5tAaLd4Trhyc,973
|
46
|
-
encommon/types/test/
|
47
|
+
encommon/types/test/test_notate.py,sha256=NfrDmMD6hOoVi9wlQ8yLZNnuHwS6Z7bLze70FkxOjSA,4008
|
48
|
+
encommon/types/test/test_strings.py,sha256=AgDXL3qiKcl1Fzx7lVsnW1ejEB13fXKpvELwG48OcSw,1084
|
47
49
|
encommon/utils/__init__.py,sha256=FJzSgfXddDXrxnencV6W4MArr3xQPEcfwrPVtMqwDHE,927
|
48
50
|
encommon/utils/common.py,sha256=N5CAo5rHIIvXzmOWwbO7R4xTYnGDqB9OYXGh0ignc_g,1355
|
49
51
|
encommon/utils/match.py,sha256=XvmmMKQ1q8_21zzPGuVvaZf6XwHXPZn4IWIYBEqVCQM,2471
|
@@ -56,8 +58,8 @@ encommon/utils/test/test_match.py,sha256=QagKpTFdRo23-Y55fSaJrSMpt5jIebScKbz0h8t
|
|
56
58
|
encommon/utils/test/test_paths.py,sha256=o7AF73jz09Mny21IsRG8vbB20mDH_oVmQFuxoSCLiOc,1919
|
57
59
|
encommon/utils/test/test_sample.py,sha256=sHAeWOL1mchTGYGQaFK_A3Z28tThuULumm9kQebnIdk,1710
|
58
60
|
encommon/utils/test/test_stdout.py,sha256=TA7xQuFoPZUYW2l00e04MGp4P9gHkkVxVflvPlhpQXg,4878
|
59
|
-
encommon-0.
|
60
|
-
encommon-0.
|
61
|
-
encommon-0.
|
62
|
-
encommon-0.
|
63
|
-
encommon-0.
|
61
|
+
encommon-0.10.0.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
|
62
|
+
encommon-0.10.0.dist-info/METADATA,sha256=ZdDOgZfbbBdsUyDoilL-X2A36N3AY4PbGHNZIAfcil4,2918
|
63
|
+
encommon-0.10.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
64
|
+
encommon-0.10.0.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
|
65
|
+
encommon-0.10.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|