encommon 0.22.6__py3-none-any.whl → 0.22.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.
- encommon/config/config.py +20 -0
- encommon/config/test/test_config.py +25 -2
- encommon/parse/jinja2.py +50 -0
- encommon/parse/test/test_jinja2.py +42 -1
- encommon/times/test/test_windows.py +3 -1
- encommon/times/window.py +7 -9
- encommon/times/windows.py +2 -2
- encommon/types/test/test_classes.py +2 -1
- encommon/version.txt +1 -1
- {encommon-0.22.6.dist-info → encommon-0.22.8.dist-info}/METADATA +1 -1
- {encommon-0.22.6.dist-info → encommon-0.22.8.dist-info}/RECORD +14 -14
- {encommon-0.22.6.dist-info → encommon-0.22.8.dist-info}/WHEEL +0 -0
- {encommon-0.22.6.dist-info → encommon-0.22.8.dist-info}/licenses/LICENSE +0 -0
- {encommon-0.22.6.dist-info → encommon-0.22.8.dist-info}/top_level.txt +0 -0
encommon/config/config.py
CHANGED
@@ -18,6 +18,7 @@ from .params import Params
|
|
18
18
|
from .paths import ConfigPaths
|
19
19
|
from .utils import config_paths
|
20
20
|
from ..crypts import Crypts
|
21
|
+
from ..parse import Jinja2
|
21
22
|
from ..types import DictStrAny
|
22
23
|
from ..types import merge_dicts
|
23
24
|
from ..types import setate
|
@@ -64,6 +65,7 @@ class Config:
|
|
64
65
|
__params: Optional[Params]
|
65
66
|
__logger: Optional[Logger]
|
66
67
|
__crypts: Optional[Crypts]
|
68
|
+
__jinja2: Jinja2
|
67
69
|
|
68
70
|
|
69
71
|
def __init__(
|
@@ -104,6 +106,11 @@ class Config:
|
|
104
106
|
self.__logger = None
|
105
107
|
self.__crypts = None
|
106
108
|
|
109
|
+
jinja2 = Jinja2({
|
110
|
+
'config': self})
|
111
|
+
|
112
|
+
self.__jinja2 = jinja2
|
113
|
+
|
107
114
|
|
108
115
|
@property
|
109
116
|
def files(
|
@@ -325,3 +332,16 @@ class Config:
|
|
325
332
|
self.__crypts = crypts
|
326
333
|
|
327
334
|
return self.__crypts
|
335
|
+
|
336
|
+
|
337
|
+
@property
|
338
|
+
def jinja2(
|
339
|
+
self,
|
340
|
+
) -> Jinja2:
|
341
|
+
"""
|
342
|
+
Return the value for the attribute from class instance.
|
343
|
+
|
344
|
+
:returns: Value for the attribute from class instance.
|
345
|
+
"""
|
346
|
+
|
347
|
+
return self.__jinja2
|
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
def test_Config(
|
27
|
+
def test_Config( # noqa: CFQ001
|
28
28
|
tmp_path: Path,
|
29
29
|
config: 'Config',
|
30
30
|
) -> None:
|
@@ -46,7 +46,8 @@ def test_Config(
|
|
46
46
|
'_Config__params',
|
47
47
|
'_Config__paths',
|
48
48
|
'_Config__logger',
|
49
|
-
'_Config__crypts'
|
49
|
+
'_Config__crypts',
|
50
|
+
'_Config__jinja2']
|
50
51
|
|
51
52
|
|
52
53
|
assert inrepr(
|
@@ -83,6 +84,8 @@ def test_Config(
|
|
83
84
|
|
84
85
|
assert config.crypts
|
85
86
|
|
87
|
+
assert config.jinja2
|
88
|
+
|
86
89
|
|
87
90
|
replaces = {
|
88
91
|
'pytemp': tmp_path,
|
@@ -138,6 +141,26 @@ def test_Config(
|
|
138
141
|
|
139
142
|
|
140
143
|
|
144
|
+
def test_Config_jinja2(
|
145
|
+
config: 'Config',
|
146
|
+
) -> None:
|
147
|
+
"""
|
148
|
+
Perform various tests associated with relevant routines.
|
149
|
+
|
150
|
+
:param config: Primary class instance for configuration.
|
151
|
+
"""
|
152
|
+
|
153
|
+
jinja2 = config.jinja2
|
154
|
+
j2parse = jinja2.parse
|
155
|
+
|
156
|
+
parsed = j2parse(
|
157
|
+
'{{ foo }}',
|
158
|
+
{'foo': 'bar'})
|
159
|
+
|
160
|
+
assert parsed == 'bar'
|
161
|
+
|
162
|
+
|
163
|
+
|
141
164
|
def test_Config_cover(
|
142
165
|
config: 'Config',
|
143
166
|
) -> None:
|
encommon/parse/jinja2.py
CHANGED
@@ -331,3 +331,53 @@ class Jinja2:
|
|
331
331
|
|
332
332
|
|
333
333
|
return value
|
334
|
+
|
335
|
+
|
336
|
+
def set_static(
|
337
|
+
self,
|
338
|
+
key: str,
|
339
|
+
value: Optional[Any] = None,
|
340
|
+
) -> None:
|
341
|
+
"""
|
342
|
+
Simply add the provided static into internal reference.
|
343
|
+
|
344
|
+
:param key: Where item will be inserted into reference.
|
345
|
+
:param value: Item that will be inserted into internal.
|
346
|
+
"""
|
347
|
+
|
348
|
+
statics = self.__statics
|
349
|
+
|
350
|
+
if value is None:
|
351
|
+
|
352
|
+
if key in statics:
|
353
|
+
del statics[key]
|
354
|
+
|
355
|
+
return None
|
356
|
+
|
357
|
+
statics[key] = value
|
358
|
+
|
359
|
+
|
360
|
+
def set_filter(
|
361
|
+
self,
|
362
|
+
key: str,
|
363
|
+
value: Optional[FILTER] = None,
|
364
|
+
) -> None:
|
365
|
+
"""
|
366
|
+
Simply add the provided filter into internal reference.
|
367
|
+
|
368
|
+
:param key: Where item will be inserted into reference.
|
369
|
+
:param value: Item that will be inserted into internal.
|
370
|
+
"""
|
371
|
+
|
372
|
+
jinjenv = self.__jinjenv
|
373
|
+
|
374
|
+
filters = jinjenv.filters
|
375
|
+
|
376
|
+
if value is None:
|
377
|
+
|
378
|
+
if key in filters:
|
379
|
+
del filters[key]
|
380
|
+
|
381
|
+
return None
|
382
|
+
|
383
|
+
filters[key] = value
|
@@ -11,6 +11,7 @@ from typing import Any
|
|
11
11
|
|
12
12
|
from pytest import fixture
|
13
13
|
from pytest import mark
|
14
|
+
from pytest import raises
|
14
15
|
|
15
16
|
from ..jinja2 import Jinja2
|
16
17
|
from ... import PROJECT
|
@@ -171,7 +172,7 @@ def test_Jinja2_literal(
|
|
171
172
|
('{{ "01" }}', '01'),
|
172
173
|
('-01', '-01'),
|
173
174
|
('{{ "-01" }}', '-01')])
|
174
|
-
def
|
175
|
+
def test_Jinja2_parse(
|
175
176
|
jinja2: Jinja2,
|
176
177
|
value: Any, # noqa: ANN401
|
177
178
|
expect: Any, # noqa: ANN401
|
@@ -189,3 +190,43 @@ def test_Jinja2_cover(
|
|
189
190
|
parsed = parse(value)
|
190
191
|
|
191
192
|
assert parsed == expect
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
def test_Jinja2_cover(
|
197
|
+
jinja2: Jinja2,
|
198
|
+
) -> None:
|
199
|
+
"""
|
200
|
+
Perform various tests associated with relevant routines.
|
201
|
+
|
202
|
+
:param jinja2: Parsing class for the Jinja2 templating.
|
203
|
+
"""
|
204
|
+
|
205
|
+
parse = jinja2.parse
|
206
|
+
|
207
|
+
|
208
|
+
jinja2.set_static(
|
209
|
+
'key', 'value')
|
210
|
+
|
211
|
+
parsed = parse('{{ key }}')
|
212
|
+
|
213
|
+
assert parsed == 'value'
|
214
|
+
|
215
|
+
jinja2.set_static('key')
|
216
|
+
|
217
|
+
with raises(Exception):
|
218
|
+
parse('{{ key }}')
|
219
|
+
|
220
|
+
|
221
|
+
jinja2.set_filter(
|
222
|
+
'float', float)
|
223
|
+
|
224
|
+
parsed = parse(
|
225
|
+
'{{ 1 | float }}')
|
226
|
+
|
227
|
+
assert parsed == 1.0
|
228
|
+
|
229
|
+
jinja2.set_filter('float')
|
230
|
+
|
231
|
+
with raises(Exception):
|
232
|
+
parse('{{ 1 | float }}')
|
encommon/times/window.py
CHANGED
@@ -31,8 +31,8 @@ class Window:
|
|
31
31
|
Example
|
32
32
|
-------
|
33
33
|
>>> window = Window('* * * * *', '-4m@m')
|
34
|
-
>>> [window.ready() for _ in range(
|
35
|
-
[True, True, True, True, False]
|
34
|
+
>>> [window.ready() for _ in range(6)]
|
35
|
+
[True, True, True, True, True, False]
|
36
36
|
|
37
37
|
:param window: Parameters for defining scheduled time.
|
38
38
|
:param start: Determine the start for scheduling window.
|
@@ -252,7 +252,7 @@ class Window:
|
|
252
252
|
raise NotImplementedError
|
253
253
|
|
254
254
|
|
255
|
-
def ready(
|
255
|
+
def ready(
|
256
256
|
self,
|
257
257
|
update: bool = True,
|
258
258
|
) -> bool:
|
@@ -283,8 +283,6 @@ class Window:
|
|
283
283
|
self.__wlast = wlast
|
284
284
|
self.__wnext = wnext
|
285
285
|
|
286
|
-
if wnext > soonest:
|
287
|
-
return False
|
288
286
|
|
289
287
|
return True
|
290
288
|
|
@@ -331,22 +329,22 @@ def window_croniter( # noqa: CFQ004
|
|
331
329
|
source: datetime,
|
332
330
|
) -> datetime:
|
333
331
|
|
334
|
-
|
332
|
+
parse = (
|
335
333
|
_operator(source)
|
336
334
|
.get_next())
|
337
335
|
|
338
|
-
return parse_time(
|
336
|
+
return parse_time(parse)
|
339
337
|
|
340
338
|
|
341
339
|
def _wlast(
|
342
340
|
source: datetime,
|
343
341
|
) -> datetime:
|
344
342
|
|
345
|
-
|
343
|
+
parse = (
|
346
344
|
_operator(source)
|
347
345
|
.get_prev())
|
348
346
|
|
349
|
-
return parse_time(
|
347
|
+
return parse_time(parse)
|
350
348
|
|
351
349
|
|
352
350
|
def _operator(
|
encommon/times/windows.py
CHANGED
@@ -94,8 +94,8 @@ class Windows:
|
|
94
94
|
>>> source = {'one': WindowParams(window=1)}
|
95
95
|
>>> params = WindowsParams(windows=source)
|
96
96
|
>>> windows = Windows(params, '-2s', 'now')
|
97
|
-
>>> [windows.ready('one') for x in range(
|
98
|
-
[True, True, False]
|
97
|
+
>>> [windows.ready('one') for x in range(4)]
|
98
|
+
[True, True, True, False]
|
99
99
|
|
100
100
|
:param params: Parameters used to instantiate the class.
|
101
101
|
:param start: Determine the start for scheduling window.
|
encommon/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.22.
|
1
|
+
0.22.8
|
@@ -1,20 +1,20 @@
|
|
1
1
|
encommon/__init__.py,sha256=YDGzuhpk5Gd1hq54LI0hw1NrrDvrJDrvH20TEy_0l5E,443
|
2
2
|
encommon/conftest.py,sha256=I7Zl2cMytnA-mwSPh0rRjsU0YSlES94jQq6mocRhVUE,1884
|
3
3
|
encommon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
encommon/version.txt,sha256=
|
4
|
+
encommon/version.txt,sha256=PWO17KUk16MCfu9n1dOBerjjrIJCvNcG3hxrb1RUDCY,7
|
5
5
|
encommon/colors/__init__.py,sha256=XRiGimMj8oo040NO5a5ZsbsIUxaGVW4tf4xWTPWgnZY,269
|
6
6
|
encommon/colors/color.py,sha256=vdOqOsJYJcrGq0b4udegrn4E8gcuVGx6iTRg3_s8Z-Q,11798
|
7
7
|
encommon/colors/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
|
8
8
|
encommon/colors/test/test_color.py,sha256=o0CRVdKhfya304IWrk0Vr1ZsmPqUyD7WxqHzG-E3KHM,4686
|
9
9
|
encommon/config/__init__.py,sha256=iZdbW7A4m7iN4xt5cEeQqo0Klqs-CaPLdD5ocLmUYi8,856
|
10
|
-
encommon/config/config.py,sha256=
|
10
|
+
encommon/config/config.py,sha256=eljTIYsJRYyH69HnGJF7O_LMU_ty6X8YzICRxTDylKQ,7381
|
11
11
|
encommon/config/files.py,sha256=dSuShvIbQXFiNmpkwNVHCKDI-phBWC03OJVUfKJnfX0,2433
|
12
12
|
encommon/config/logger.py,sha256=MsGng6k1m4r5DnFkX8PhO33nj26AyiRYrKtFkjhAuNo,14556
|
13
13
|
encommon/config/params.py,sha256=FtcWi3-CY6OHLN7o3S-iBktpS1yGt5wLVD0546XEKRY,2223
|
14
14
|
encommon/config/paths.py,sha256=6eLhqEXDyNQpwdL6QWNPf060uayuUzXyM6A3ikNC24Q,2585
|
15
15
|
encommon/config/utils.py,sha256=jZ9x6Nd7H4XZMSyAFr7mydgIu8P7xBzjHqKzMpmduw0,2127
|
16
16
|
encommon/config/test/__init__.py,sha256=Vs5Pca7QBgoyoSjk6DSpO0YFcqkUhap5-VLbaCn8MjA,304
|
17
|
-
encommon/config/test/test_config.py,sha256
|
17
|
+
encommon/config/test/test_config.py,sha256=-P9Exy0WTZSvsF30kAFux1z9zuJhdDF3mCwQ5irNx2A,3406
|
18
18
|
encommon/config/test/test_files.py,sha256=xhR6-FUqTDaMcK7cUMWuyL9x2rSu6dmJUy_J6r1cHBM,2345
|
19
19
|
encommon/config/test/test_logger.py,sha256=hCFedEwbZinlYZ2qzUkiH6mhqFdAv3NYJy6-OX091kU,5626
|
20
20
|
encommon/config/test/test_paths.py,sha256=emkDpz7W2TMdH3-wEy4ZYcrufiwRVKT6w_U5rEVp06o,2693
|
@@ -27,10 +27,10 @@ encommon/crypts/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLE
|
|
27
27
|
encommon/crypts/test/test_crypts.py,sha256=YKB4Kra-5CRQ8gsLLCYj2s4mjlPuibszUWClPDvMYk0,3504
|
28
28
|
encommon/crypts/test/test_hashes.py,sha256=HEvKHTkWy6Xehh5fRHmntovGbkjWEgMsrVQCmMCBLtA,1223
|
29
29
|
encommon/parse/__init__.py,sha256=6uV4GCm_nOYC77x2jQvTDsa0F6vBGRbCgju_HCc96zM,422
|
30
|
-
encommon/parse/jinja2.py,sha256=
|
30
|
+
encommon/parse/jinja2.py,sha256=x7h9hwnlgY9pbyaP5Yu2NM9dKg0Um8RPPGArjkwumeQ,8101
|
31
31
|
encommon/parse/network.py,sha256=V2JvQ4XHUeo4wxNycXroBHDz8gLgo6BI9wJkr0f4qjc,8770
|
32
32
|
encommon/parse/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
|
33
|
-
encommon/parse/test/test_jinja2.py,sha256=
|
33
|
+
encommon/parse/test/test_jinja2.py,sha256=8H4ZErFgBCxEsgMQdp0GpVhgn6SnseVpfE0cDCAjCOc,4444
|
34
34
|
encommon/parse/test/test_network.py,sha256=-6FmgMzpDAZ4SI6Ccq4jUm9RYtanV24W9aTJyK6Y0W4,4170
|
35
35
|
encommon/times/__init__.py,sha256=QX4iuZ59UlsMbEWbubnVJXJtrOubNxAAAv510urcLUA,972
|
36
36
|
encommon/times/common.py,sha256=tLlQUKU-KMrf1Dy_9qgg2J-8ytVpyqPs5ZXV9_TlvVk,1036
|
@@ -42,8 +42,8 @@ encommon/times/timer.py,sha256=xxS6KVXFuRLq-RkXWMR7MMX5x0HGrEhLlOhRCecuCZY,3225
|
|
42
42
|
encommon/times/timers.py,sha256=4kRUd_posGCLSi6hW8aBDypNgnUjnfkbuKpAr4mjOLg,9815
|
43
43
|
encommon/times/unitime.py,sha256=MwYUJBdX_Rj7pW8QoMtZMUyHa4lsdZKryTdBCpVjnpY,1316
|
44
44
|
encommon/times/utils.py,sha256=PJ5QsKb3_pYEnD3Sz81d8QDhYQtTIj4HJfMoC9gNwmo,3100
|
45
|
-
encommon/times/window.py,sha256=
|
46
|
-
encommon/times/windows.py,sha256=
|
45
|
+
encommon/times/window.py,sha256=_b55R4U5X5oeTS2PbTZHfOaNANl2WM2TRCP4-J6QLnE,8423
|
46
|
+
encommon/times/windows.py,sha256=mdoOMF4Igyw-mZGMqr2e4s22iFCijeqamCfiyFrRjlY,10867
|
47
47
|
encommon/times/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
|
48
48
|
encommon/times/test/test_duration.py,sha256=3Tw6Y_ah36GCJl4vZ76z4Jt7rIxcm9P18-A69qsbLjI,4224
|
49
49
|
encommon/times/test/test_params.py,sha256=kHvs-WvKfPQCdCDnPU9tAyMVXmzH3eUjwQN-QdWBeh4,1407
|
@@ -54,7 +54,7 @@ encommon/times/test/test_timers.py,sha256=HePWaNNH4MTDZoa2H-S_XkmN32lZLXW3g5xv-z
|
|
54
54
|
encommon/times/test/test_unitime.py,sha256=5i4UjBCw8R9h-Lw963GfB_dHBMEQhjvv1k-t27Wyyls,510
|
55
55
|
encommon/times/test/test_utils.py,sha256=WkzHJY6zOt02Ujg5FItOo1nPtktz5ss8ODmG1tRQaaw,2056
|
56
56
|
encommon/times/test/test_window.py,sha256=6ySO5DaYzg1bsVNCqB6u71rKWc0vpolxQ09ruoswN2c,6138
|
57
|
-
encommon/times/test/test_windows.py,sha256=
|
57
|
+
encommon/times/test/test_windows.py,sha256=HTn34YvDS56rAFm6T0fQ0DE7zF2TvWWHJr7hxj6kwz4,4515
|
58
58
|
encommon/types/__init__.py,sha256=rly7loMD1R7YU83u90KqPYiifjZAX_UAXpVGcB_Xerk,1269
|
59
59
|
encommon/types/classes.py,sha256=FYFTu8Uj-74JWudHOlhaOrsXXPxitorBfM9_QM3EGSU,1689
|
60
60
|
encommon/types/dicts.py,sha256=IuLoVdtilhM83ujT74mcz0Zi1HI87P4k7wjnnyMxPag,2821
|
@@ -65,7 +65,7 @@ encommon/types/notate.py,sha256=xcvifAe5tXVK0NoxE5P-OEbJXp4UYa5RGsXU-A1TKA4,1069
|
|
65
65
|
encommon/types/strings.py,sha256=LW2WZND64cKE1LhNip3vqsoP3elLsUP6cpS0dYnUKGE,2800
|
66
66
|
encommon/types/types.py,sha256=DbzdDLLclD1Gk8bmyhDUUWVDnJ5LdaolLV3JYKHFVgA,322
|
67
67
|
encommon/types/test/__init__.py,sha256=WZm1yZbFd2VQg-E1b6a02E6V2QXmIWiW5TIiKFFPV-s,910
|
68
|
-
encommon/types/test/test_classes.py,sha256=
|
68
|
+
encommon/types/test/test_classes.py,sha256=PopL2yuB9-JaEor6fUJkK9TZ9-SRfYWAIH8ZZd-mGbI,1502
|
69
69
|
encommon/types/test/test_dicts.py,sha256=W--IcPwvdKaFGs_00tvWBGziFSA0wtDQMuPk4rl0gKU,3651
|
70
70
|
encommon/types/test/test_empty.py,sha256=eLsHuqq2YNABFkMLPbGbJMXeW2nyGNIxzUZv7YhPT5U,1017
|
71
71
|
encommon/types/test/test_funcs.py,sha256=dYVJgihEj1j3F-OxH0mYSIMoDwZbjvgMnvJKea8MZJc,664
|
@@ -131,8 +131,8 @@ encommon/webkit/test/test_moderate.py,sha256=KitKGBtwHOQm0pXXZA5nl9MwAi2pbHOsKhM
|
|
131
131
|
encommon/webkit/test/test_numeric.py,sha256=9Jqiyo-Bh572QJSyd3gqRwYTifnqqzE7_cNCmLn0CG0,3531
|
132
132
|
encommon/webkit/test/test_statate.py,sha256=4VvmyJhsK3TSK-hq3TzkzwPkXY-GPTU_7uJf-zG_y_s,1760
|
133
133
|
encommon/webkit/test/test_tagues.py,sha256=LQWk6rSBoBxAu-YmUOU8uWNki5RBzk5lp0dbFpySg68,1431
|
134
|
-
encommon-0.22.
|
135
|
-
encommon-0.22.
|
136
|
-
encommon-0.22.
|
137
|
-
encommon-0.22.
|
138
|
-
encommon-0.22.
|
134
|
+
encommon-0.22.8.dist-info/licenses/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
|
135
|
+
encommon-0.22.8.dist-info/METADATA,sha256=y0Sf05hR54o4Ofj2J8LN9jOqN5tiXTzjwA7Qy6np3vY,4304
|
136
|
+
encommon-0.22.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
137
|
+
encommon-0.22.8.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
|
138
|
+
encommon-0.22.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|