encommon 0.14.0__py3-none-any.whl → 0.15.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/colors/__init__.py +2 -2
- encommon/colors/{colors.py → color.py} +24 -24
- encommon/colors/test/{test_colors.py → test_color.py} +16 -16
- encommon/config/config.py +15 -15
- encommon/config/files.py +14 -14
- encommon/config/logger.py +6 -6
- encommon/config/params.py +47 -30
- encommon/config/paths.py +13 -13
- encommon/config/test/__init__.py +1 -1
- encommon/config/test/test_config.py +10 -16
- encommon/config/test/test_files.py +8 -7
- encommon/config/test/test_logger.py +11 -10
- encommon/config/test/test_paths.py +11 -10
- encommon/config/utils.py +2 -2
- encommon/crypts/params.py +28 -12
- encommon/crypts/test/test_crypts.py +5 -5
- encommon/crypts/test/test_hashes.py +2 -1
- encommon/times/__init__.py +2 -2
- encommon/times/common.py +2 -2
- encommon/times/params.py +76 -48
- encommon/times/parse.py +3 -3
- encommon/times/test/test_duration.py +3 -2
- encommon/times/test/test_time.py +123 -0
- encommon/times/test/test_timer.py +5 -4
- encommon/times/test/test_timers.py +10 -9
- encommon/times/test/test_window.py +4 -3
- encommon/times/test/test_windows.py +7 -6
- encommon/times/{times.py → time.py} +61 -12
- encommon/times/timer.py +10 -10
- encommon/times/timers.py +3 -3
- encommon/times/unitime.py +9 -0
- encommon/times/window.py +31 -31
- encommon/times/windows.py +10 -10
- encommon/types/classes.py +0 -13
- encommon/types/lists.py +6 -0
- encommon/types/notate.py +2 -1
- encommon/types/strings.py +5 -0
- encommon/types/test/test_empty.py +2 -1
- encommon/utils/sample.py +6 -5
- encommon/utils/stdout.py +2 -2
- encommon/utils/test/test_paths.py +3 -3
- encommon/utils/test/test_sample.py +2 -2
- encommon/utils/test/test_stdout.py +3 -3
- encommon/version.txt +1 -1
- {encommon-0.14.0.dist-info → encommon-0.15.0.dist-info}/METADATA +1 -1
- encommon-0.15.0.dist-info/RECORD +84 -0
- {encommon-0.14.0.dist-info → encommon-0.15.0.dist-info}/WHEEL +1 -1
- encommon/times/test/test_times.py +0 -122
- encommon-0.14.0.dist-info/RECORD +0 -84
- {encommon-0.14.0.dist-info → encommon-0.15.0.dist-info}/LICENSE +0 -0
- {encommon-0.14.0.dist-info → encommon-0.15.0.dist-info}/top_level.txt +0 -0
encommon/colors/__init__.py
CHANGED
@@ -14,13 +14,13 @@ from ..types import strplwr
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
class
|
17
|
+
class Color:
|
18
18
|
"""
|
19
19
|
Covert colors to various forms using provided hex value.
|
20
20
|
|
21
21
|
Example
|
22
22
|
-------
|
23
|
-
>>> color =
|
23
|
+
>>> color = Color('#003333')
|
24
24
|
>>> color.rgb
|
25
25
|
(0, 51, 51)
|
26
26
|
>>> color.hsl
|
@@ -32,12 +32,12 @@ class Colors:
|
|
32
32
|
|
33
33
|
Example
|
34
34
|
-------
|
35
|
-
>>> color1 =
|
36
|
-
>>> color2 =
|
35
|
+
>>> color1 = Color('#003333')
|
36
|
+
>>> color2 = Color('#330000')
|
37
37
|
>>> color1 - color2
|
38
|
-
|
38
|
+
Color('#32CCCD')
|
39
39
|
>>> color1 + color2
|
40
|
-
|
40
|
+
Color('#333333')
|
41
41
|
|
42
42
|
:param source: Source color used when converting values.
|
43
43
|
"""
|
@@ -72,7 +72,7 @@ class Colors:
|
|
72
72
|
|
73
73
|
color = self.__str__()
|
74
74
|
|
75
|
-
return f"
|
75
|
+
return f"Color('{color}')"
|
76
76
|
|
77
77
|
|
78
78
|
def __hash__(
|
@@ -130,8 +130,8 @@ class Colors:
|
|
130
130
|
|
131
131
|
def __add__(
|
132
132
|
self,
|
133
|
-
other: Union[int, str, '
|
134
|
-
) -> '
|
133
|
+
other: Union[int, str, 'Color'],
|
134
|
+
) -> 'Color':
|
135
135
|
"""
|
136
136
|
Built-in method for mathematically processing the value.
|
137
137
|
|
@@ -140,7 +140,7 @@ class Colors:
|
|
140
140
|
"""
|
141
141
|
|
142
142
|
if isinstance(other, str):
|
143
|
-
other =
|
143
|
+
other = Color(other)
|
144
144
|
|
145
145
|
source = self.__int__()
|
146
146
|
_source = int(other)
|
@@ -149,13 +149,13 @@ class Colors:
|
|
149
149
|
|
150
150
|
result = f'{outcome:06x}'
|
151
151
|
|
152
|
-
return
|
152
|
+
return Color(result)
|
153
153
|
|
154
154
|
|
155
155
|
def __sub__(
|
156
156
|
self,
|
157
|
-
other: Union[int, str, '
|
158
|
-
) -> '
|
157
|
+
other: Union[int, str, 'Color'],
|
158
|
+
) -> 'Color':
|
159
159
|
"""
|
160
160
|
Built-in method for mathematically processing the value.
|
161
161
|
|
@@ -164,7 +164,7 @@ class Colors:
|
|
164
164
|
"""
|
165
165
|
|
166
166
|
if isinstance(other, str):
|
167
|
-
other =
|
167
|
+
other = Color(other)
|
168
168
|
|
169
169
|
source = self.__int__()
|
170
170
|
_source = int(other)
|
@@ -173,7 +173,7 @@ class Colors:
|
|
173
173
|
|
174
174
|
result = f'{outcome:06x}'
|
175
175
|
|
176
|
-
return
|
176
|
+
return Color(result)
|
177
177
|
|
178
178
|
|
179
179
|
def __eq__(
|
@@ -193,7 +193,7 @@ class Colors:
|
|
193
193
|
other = f'{other:06x}'
|
194
194
|
|
195
195
|
if isinstance(other, str):
|
196
|
-
other =
|
196
|
+
other = Color(other)
|
197
197
|
|
198
198
|
assert hasattr(other, 'source')
|
199
199
|
|
@@ -223,7 +223,7 @@ class Colors:
|
|
223
223
|
|
224
224
|
def __gt__(
|
225
225
|
self,
|
226
|
-
other: Union[int, str, '
|
226
|
+
other: Union[int, str, 'Color'],
|
227
227
|
) -> bool:
|
228
228
|
"""
|
229
229
|
Built-in method for comparing this instance with another.
|
@@ -238,7 +238,7 @@ class Colors:
|
|
238
238
|
other = f'{other:06x}'
|
239
239
|
|
240
240
|
if isinstance(other, str):
|
241
|
-
other =
|
241
|
+
other = Color(other)
|
242
242
|
|
243
243
|
assert hasattr(other, 'source')
|
244
244
|
|
@@ -254,7 +254,7 @@ class Colors:
|
|
254
254
|
|
255
255
|
def __ge__(
|
256
256
|
self,
|
257
|
-
other: Union[int, str, '
|
257
|
+
other: Union[int, str, 'Color'],
|
258
258
|
) -> bool:
|
259
259
|
"""
|
260
260
|
Built-in method for comparing this instance with another.
|
@@ -269,7 +269,7 @@ class Colors:
|
|
269
269
|
other = f'{other:06x}'
|
270
270
|
|
271
271
|
if isinstance(other, str):
|
272
|
-
other =
|
272
|
+
other = Color(other)
|
273
273
|
|
274
274
|
assert hasattr(other, 'source')
|
275
275
|
|
@@ -285,7 +285,7 @@ class Colors:
|
|
285
285
|
|
286
286
|
def __lt__(
|
287
287
|
self,
|
288
|
-
other: Union[int, str, '
|
288
|
+
other: Union[int, str, 'Color'],
|
289
289
|
) -> bool:
|
290
290
|
"""
|
291
291
|
Built-in method for comparing this instance with another.
|
@@ -300,7 +300,7 @@ class Colors:
|
|
300
300
|
other = f'{other:06x}'
|
301
301
|
|
302
302
|
if isinstance(other, str):
|
303
|
-
other =
|
303
|
+
other = Color(other)
|
304
304
|
|
305
305
|
assert hasattr(other, 'source')
|
306
306
|
|
@@ -316,7 +316,7 @@ class Colors:
|
|
316
316
|
|
317
317
|
def __le__(
|
318
318
|
self,
|
319
|
-
other: Union[int, str, '
|
319
|
+
other: Union[int, str, 'Color'],
|
320
320
|
) -> bool:
|
321
321
|
"""
|
322
322
|
Built-in method for comparing this instance with another.
|
@@ -331,7 +331,7 @@ class Colors:
|
|
331
331
|
other = f'{other:06x}'
|
332
332
|
|
333
333
|
if isinstance(other, str):
|
334
|
-
other =
|
334
|
+
other = Color(other)
|
335
335
|
|
336
336
|
assert hasattr(other, 'source')
|
337
337
|
|
@@ -9,27 +9,27 @@ is permitted, for more information consult the project license file.
|
|
9
9
|
|
10
10
|
from pytest import mark
|
11
11
|
|
12
|
-
from ..
|
12
|
+
from ..color import Color
|
13
13
|
from ...types import lattrs
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
def
|
17
|
+
def test_Color() -> None:
|
18
18
|
"""
|
19
19
|
Perform various tests associated with relevant routines.
|
20
20
|
"""
|
21
21
|
|
22
|
-
color =
|
22
|
+
color = Color('000001')
|
23
23
|
|
24
24
|
|
25
25
|
attrs = lattrs(color)
|
26
26
|
|
27
27
|
assert attrs == [
|
28
|
-
'
|
28
|
+
'_Color__source']
|
29
29
|
|
30
30
|
|
31
31
|
assert repr(color) == (
|
32
|
-
"
|
32
|
+
"Color('#000001')")
|
33
33
|
|
34
34
|
assert hash(color) > 0
|
35
35
|
|
@@ -71,7 +71,7 @@ def test_Colors() -> None:
|
|
71
71
|
('00ffff', (0, 255, 255)),
|
72
72
|
('ff00ff', (255, 0, 255)),
|
73
73
|
('800080', (128, 0, 128))])
|
74
|
-
def
|
74
|
+
def test_Color_rgb(
|
75
75
|
source: str,
|
76
76
|
expect: tuple[int, ...],
|
77
77
|
) -> None:
|
@@ -82,7 +82,7 @@ def test_Colors_rgb(
|
|
82
82
|
:param expect: Expected output from the testing routine.
|
83
83
|
"""
|
84
84
|
|
85
|
-
assert
|
85
|
+
assert Color(source).rgb == expect
|
86
86
|
|
87
87
|
|
88
88
|
|
@@ -99,7 +99,7 @@ def test_Colors_rgb(
|
|
99
99
|
('00ffff', (53.8100, 78.7400, 106.9700)),
|
100
100
|
('ff00ff', (59.2900, 28.4800, 96.9800)),
|
101
101
|
('800080', (12.7984, 6.1477, 20.9342))])
|
102
|
-
def
|
102
|
+
def test_Color_xyz(
|
103
103
|
source: str,
|
104
104
|
expect: tuple[int, ...],
|
105
105
|
) -> None:
|
@@ -110,7 +110,7 @@ def test_Colors_xyz(
|
|
110
110
|
:param expect: Expected output from the testing routine.
|
111
111
|
"""
|
112
112
|
|
113
|
-
assert
|
113
|
+
assert Color(source).xyz == expect
|
114
114
|
|
115
115
|
|
116
116
|
|
@@ -127,7 +127,7 @@ def test_Colors_xyz(
|
|
127
127
|
('00ffff', (0.2247, 0.3287)),
|
128
128
|
('ff00ff', (0.3209, 0.1542)),
|
129
129
|
('800080', (0.3209, 0.1542))])
|
130
|
-
def
|
130
|
+
def test_Color_xy(
|
131
131
|
source: str,
|
132
132
|
expect: tuple[int, ...],
|
133
133
|
) -> None:
|
@@ -138,7 +138,7 @@ def test_Colors_xy(
|
|
138
138
|
:param expect: Expected output from the testing routine.
|
139
139
|
"""
|
140
140
|
|
141
|
-
assert
|
141
|
+
assert Color(source).xy == expect
|
142
142
|
|
143
143
|
|
144
144
|
|
@@ -155,7 +155,7 @@ def test_Colors_xy(
|
|
155
155
|
('00ffff', (180, 100, 50)),
|
156
156
|
('ff00ff', (300, 100, 50)),
|
157
157
|
('800080', (300, 100, 25))])
|
158
|
-
def
|
158
|
+
def test_Color_hsl(
|
159
159
|
source: str,
|
160
160
|
expect: tuple[int, ...],
|
161
161
|
) -> None:
|
@@ -166,17 +166,17 @@ def test_Colors_hsl(
|
|
166
166
|
:param expect: Expected output from the testing routine.
|
167
167
|
"""
|
168
168
|
|
169
|
-
assert
|
169
|
+
assert Color(source).hsl == expect
|
170
170
|
|
171
171
|
|
172
172
|
|
173
|
-
def
|
173
|
+
def test_Color_cover() -> None:
|
174
174
|
"""
|
175
175
|
Perform various tests associated with relevant routines.
|
176
176
|
"""
|
177
177
|
|
178
|
-
color1 =
|
179
|
-
color2 =
|
178
|
+
color1 = Color('000001')
|
179
|
+
color2 = Color('#000001')
|
180
180
|
|
181
181
|
assert not (color1 > None) # type: ignore
|
182
182
|
assert not (color1 >= None) # type: ignore
|
encommon/config/config.py
CHANGED
@@ -8,7 +8,6 @@ is permitted, for more information consult the project license file.
|
|
8
8
|
|
9
9
|
|
10
10
|
from copy import deepcopy
|
11
|
-
from typing import Any
|
12
11
|
from typing import Callable
|
13
12
|
from typing import Optional
|
14
13
|
from typing import TYPE_CHECKING
|
@@ -19,6 +18,7 @@ from .params import Params
|
|
19
18
|
from .paths import ConfigPaths
|
20
19
|
from .utils import config_paths
|
21
20
|
from ..crypts import Crypts
|
21
|
+
from ..types import DictStrAny
|
22
22
|
from ..types import merge_dicts
|
23
23
|
from ..types import setate
|
24
24
|
|
@@ -55,8 +55,8 @@ class Config:
|
|
55
55
|
|
56
56
|
__files: ConfigFiles
|
57
57
|
__paths: ConfigPaths
|
58
|
-
__cargs:
|
59
|
-
__sargs:
|
58
|
+
__cargs: DictStrAny
|
59
|
+
__sargs: DictStrAny
|
60
60
|
|
61
61
|
__model: Callable # type: ignore
|
62
62
|
|
@@ -70,8 +70,8 @@ class Config:
|
|
70
70
|
files: Optional['PATHABLE'] = None,
|
71
71
|
*,
|
72
72
|
paths: Optional['PATHABLE'] = None,
|
73
|
-
cargs: Optional[
|
74
|
-
sargs: Optional[
|
73
|
+
cargs: Optional[DictStrAny] = None,
|
74
|
+
sargs: Optional[DictStrAny] = None,
|
75
75
|
model: Optional[Callable] = None, # type: ignore
|
76
76
|
) -> None:
|
77
77
|
"""
|
@@ -133,14 +133,14 @@ class Config:
|
|
133
133
|
@property
|
134
134
|
def cargs(
|
135
135
|
self,
|
136
|
-
) ->
|
136
|
+
) -> DictStrAny:
|
137
137
|
"""
|
138
138
|
Return the value for the attribute from class instance.
|
139
139
|
|
140
140
|
:returns: Value for the attribute from class instance.
|
141
141
|
"""
|
142
142
|
|
143
|
-
returned:
|
143
|
+
returned: DictStrAny = {}
|
144
144
|
|
145
145
|
cargs = deepcopy(self.__cargs)
|
146
146
|
|
@@ -155,14 +155,14 @@ class Config:
|
|
155
155
|
@property
|
156
156
|
def sargs(
|
157
157
|
self,
|
158
|
-
) ->
|
158
|
+
) -> DictStrAny:
|
159
159
|
"""
|
160
160
|
Return the value for the attribute from class instance.
|
161
161
|
|
162
162
|
:returns: Value for the attribute from class instance.
|
163
163
|
"""
|
164
164
|
|
165
|
-
returned:
|
165
|
+
returned: DictStrAny = {}
|
166
166
|
|
167
167
|
sargs = deepcopy(self.__sargs)
|
168
168
|
|
@@ -177,7 +177,7 @@ class Config:
|
|
177
177
|
@property
|
178
178
|
def config(
|
179
179
|
self,
|
180
|
-
) ->
|
180
|
+
) -> DictStrAny:
|
181
181
|
"""
|
182
182
|
Return the configuration dumped from the Pydantic model.
|
183
183
|
|
@@ -190,7 +190,7 @@ class Config:
|
|
190
190
|
@property
|
191
191
|
def basic(
|
192
192
|
self,
|
193
|
-
) ->
|
193
|
+
) -> DictStrAny:
|
194
194
|
"""
|
195
195
|
Return the configuration source loaded from the objects.
|
196
196
|
|
@@ -199,7 +199,7 @@ class Config:
|
|
199
199
|
|
200
200
|
files = self.files
|
201
201
|
|
202
|
-
ferged = files.
|
202
|
+
ferged = files.merge
|
203
203
|
|
204
204
|
merge_dicts(
|
205
205
|
dict1=ferged,
|
@@ -212,7 +212,7 @@ class Config:
|
|
212
212
|
@property
|
213
213
|
def merge(
|
214
214
|
self,
|
215
|
-
) ->
|
215
|
+
) -> DictStrAny:
|
216
216
|
"""
|
217
217
|
Return the configuration source loaded from the objects.
|
218
218
|
|
@@ -222,8 +222,8 @@ class Config:
|
|
222
222
|
files = self.files
|
223
223
|
paths = self.paths
|
224
224
|
|
225
|
-
ferged = files.
|
226
|
-
perged = paths.
|
225
|
+
ferged = files.merge
|
226
|
+
perged = paths.merge
|
227
227
|
|
228
228
|
merge_dicts(
|
229
229
|
dict1=ferged,
|
encommon/config/files.py
CHANGED
@@ -9,13 +9,13 @@ is permitted, for more information consult the project license file.
|
|
9
9
|
|
10
10
|
from copy import deepcopy
|
11
11
|
from pathlib import Path
|
12
|
-
from typing import Any
|
13
12
|
from typing import Optional
|
14
13
|
from typing import TYPE_CHECKING
|
15
14
|
|
16
15
|
from .utils import config_load
|
17
16
|
from .utils import config_path
|
18
17
|
from .utils import config_paths
|
18
|
+
from ..types import DictStrAny
|
19
19
|
from ..types import merge_dicts
|
20
20
|
from ..types import sort_dict
|
21
21
|
|
@@ -32,7 +32,7 @@ class ConfigFile:
|
|
32
32
|
"""
|
33
33
|
|
34
34
|
path: Path
|
35
|
-
config:
|
35
|
+
config: DictStrAny
|
36
36
|
|
37
37
|
|
38
38
|
def __init__(
|
@@ -62,7 +62,7 @@ class ConfigFiles:
|
|
62
62
|
paths: tuple[Path, ...]
|
63
63
|
config: dict[str, ConfigFile]
|
64
64
|
|
65
|
-
|
65
|
+
__merge: Optional[DictStrAny]
|
66
66
|
|
67
67
|
|
68
68
|
def __init__(
|
@@ -80,13 +80,13 @@ class ConfigFiles:
|
|
80
80
|
str(x): ConfigFile(x)
|
81
81
|
for x in self.paths}
|
82
82
|
|
83
|
-
self.
|
83
|
+
self.__merge = None
|
84
84
|
|
85
85
|
|
86
86
|
@property
|
87
|
-
def
|
87
|
+
def merge(
|
88
88
|
self,
|
89
|
-
) ->
|
89
|
+
) -> DictStrAny:
|
90
90
|
"""
|
91
91
|
Return the configuration in dictionary format for files.
|
92
92
|
|
@@ -94,12 +94,12 @@ class ConfigFiles:
|
|
94
94
|
"""
|
95
95
|
|
96
96
|
config = self.config
|
97
|
-
|
97
|
+
merge = self.__merge
|
98
98
|
|
99
|
-
if
|
100
|
-
return deepcopy(
|
99
|
+
if merge is not None:
|
100
|
+
return deepcopy(merge)
|
101
101
|
|
102
|
-
|
102
|
+
merge = {}
|
103
103
|
|
104
104
|
|
105
105
|
for file in config.values():
|
@@ -107,13 +107,13 @@ class ConfigFiles:
|
|
107
107
|
source = file.config
|
108
108
|
|
109
109
|
merge_dicts(
|
110
|
-
dict1=
|
110
|
+
dict1=merge,
|
111
111
|
dict2=deepcopy(source),
|
112
112
|
force=False)
|
113
113
|
|
114
114
|
|
115
|
-
|
115
|
+
merge = sort_dict(merge)
|
116
116
|
|
117
|
-
self.
|
117
|
+
self.__merge = merge
|
118
118
|
|
119
|
-
return deepcopy(
|
119
|
+
return deepcopy(merge)
|
encommon/config/logger.py
CHANGED
@@ -28,7 +28,7 @@ from typing import Optional
|
|
28
28
|
from typing import TYPE_CHECKING
|
29
29
|
|
30
30
|
from .utils import config_path
|
31
|
-
from ..times import
|
31
|
+
from ..times import Time
|
32
32
|
from ..types import Empty
|
33
33
|
from ..types.strings import COMMAD
|
34
34
|
from ..types.strings import COMMAS
|
@@ -83,7 +83,7 @@ class Message:
|
|
83
83
|
"""
|
84
84
|
|
85
85
|
__level: LOGLEVELS
|
86
|
-
__time:
|
86
|
+
__time: Time
|
87
87
|
__fields: dict[str, str] = {}
|
88
88
|
|
89
89
|
|
@@ -98,7 +98,7 @@ class Message:
|
|
98
98
|
"""
|
99
99
|
|
100
100
|
self.__level = level
|
101
|
-
self.__time =
|
101
|
+
self.__time = Time(time)
|
102
102
|
self.__fields = {}
|
103
103
|
|
104
104
|
items = kwargs.items()
|
@@ -122,7 +122,7 @@ class Message:
|
|
122
122
|
value = COMMAD.join(values)
|
123
123
|
|
124
124
|
|
125
|
-
if (isinstance(value,
|
125
|
+
if (isinstance(value, Time)
|
126
126
|
and key == 'elapsed'):
|
127
127
|
value = value.since
|
128
128
|
|
@@ -188,14 +188,14 @@ class Message:
|
|
188
188
|
@property
|
189
189
|
def time(
|
190
190
|
self,
|
191
|
-
) ->
|
191
|
+
) -> Time:
|
192
192
|
"""
|
193
193
|
Return the value for the attribute from class instance.
|
194
194
|
|
195
195
|
:returns: Value for the attribute from class instance.
|
196
196
|
"""
|
197
197
|
|
198
|
-
return
|
198
|
+
return Time(self.__time)
|
199
199
|
|
200
200
|
|
201
201
|
@property
|
encommon/config/params.py
CHANGED
@@ -8,8 +8,12 @@ is permitted, for more information consult the project license file.
|
|
8
8
|
|
9
9
|
|
10
10
|
from pathlib import Path
|
11
|
+
from typing import Annotated
|
12
|
+
from typing import Any
|
11
13
|
from typing import Optional
|
12
14
|
|
15
|
+
from pydantic import Field
|
16
|
+
|
13
17
|
from .logger import LOGLEVELS
|
14
18
|
from ..crypts import CryptsParams
|
15
19
|
from ..types import BaseModel
|
@@ -19,61 +23,74 @@ from ..types import BaseModel
|
|
19
23
|
class ConfigParams(BaseModel, extra='forbid'):
|
20
24
|
"""
|
21
25
|
Process and validate the core configuration parameters.
|
22
|
-
|
23
|
-
:param paths: Complete or relative path to config paths.
|
24
|
-
:param data: Keyword arguments passed to Pydantic model.
|
25
|
-
Parameter is picked up by autodoc, please ignore.
|
26
26
|
"""
|
27
27
|
|
28
|
-
paths:
|
28
|
+
paths: Annotated[
|
29
|
+
Optional[list[str]],
|
30
|
+
Field(None,
|
31
|
+
description='Location of configuration files',
|
32
|
+
min_length=1)]
|
29
33
|
|
30
34
|
|
31
35
|
|
32
36
|
class LoggerParams(BaseModel, extra='forbid'):
|
33
37
|
"""
|
34
38
|
Process and validate the core configuration parameters.
|
35
|
-
|
36
|
-
:param stdo_level: Minimum level for the message to pass.
|
37
|
-
:param file_level: Minimum level for the message to pass.
|
38
|
-
:param file_path: Enables writing to the filesystem path.
|
39
39
|
"""
|
40
40
|
|
41
|
-
stdo_level:
|
42
|
-
|
43
|
-
|
41
|
+
stdo_level: Annotated[
|
42
|
+
Optional[LOGLEVELS],
|
43
|
+
Field(None,
|
44
|
+
description='Minimum logging message level',
|
45
|
+
min_length=1)]
|
46
|
+
|
47
|
+
file_level: Annotated[
|
48
|
+
Optional[LOGLEVELS],
|
49
|
+
Field(None,
|
50
|
+
description='Minimum logging message level',
|
51
|
+
min_length=1)]
|
52
|
+
|
53
|
+
file_path: Annotated[
|
54
|
+
Optional[str],
|
55
|
+
Field(None,
|
56
|
+
description='Enable output to the log file',
|
57
|
+
min_length=1)]
|
44
58
|
|
45
59
|
|
46
60
|
def __init__(
|
47
61
|
self,
|
48
|
-
|
49
|
-
|
50
|
-
file_path: Optional[str | Path] = None,
|
62
|
+
/,
|
63
|
+
**data: Any,
|
51
64
|
) -> None:
|
52
65
|
"""
|
53
66
|
Initialize instance for class using provided parameters.
|
54
67
|
"""
|
55
68
|
|
56
|
-
|
57
|
-
file_path = str(file_path)
|
69
|
+
file_path = data.get('file_path')
|
58
70
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
71
|
+
if isinstance(file_path, Path):
|
72
|
+
data['file_path'] = str(file_path)
|
73
|
+
|
74
|
+
super().__init__(**data)
|
63
75
|
|
64
76
|
|
65
77
|
|
66
78
|
class Params(BaseModel, extra='forbid'):
|
67
79
|
"""
|
68
80
|
Process and validate the core configuration parameters.
|
69
|
-
|
70
|
-
:param enconfig: Configuration for the Config instance.
|
71
|
-
:param enlogger: Configuration for the Logger instance.
|
72
|
-
:param encrypts: Configuration for the Crypts instance.
|
73
|
-
:param data: Keyword arguments passed to Pydantic model.
|
74
|
-
Parameter is picked up by autodoc, please ignore.
|
75
81
|
"""
|
76
82
|
|
77
|
-
enconfig:
|
78
|
-
|
79
|
-
|
83
|
+
enconfig: Annotated[
|
84
|
+
Optional[ConfigParams],
|
85
|
+
Field(None,
|
86
|
+
description='Parameters for Config instance')]
|
87
|
+
|
88
|
+
enlogger: Annotated[
|
89
|
+
Optional[LoggerParams],
|
90
|
+
Field(None,
|
91
|
+
description='Parameters for Logger instance')]
|
92
|
+
|
93
|
+
encrypts: Annotated[
|
94
|
+
Optional[CryptsParams],
|
95
|
+
Field(None,
|
96
|
+
description='Parameters for Crypts instance')]
|