encommon 0.7.5__tar.gz → 0.8.0__tar.gz
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-0.7.5/encommon.egg-info → encommon-0.8.0}/PKG-INFO +1 -1
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/__init__.py +4 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/common.py +18 -14
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/config.py +8 -5
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/files.py +13 -7
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/logger.py +94 -88
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/params.py +1 -1
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/paths.py +16 -8
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/test/test_common.py +27 -4
- encommon-0.8.0/encommon/config/test/test_config.py +117 -0
- encommon-0.8.0/encommon/config/test/test_files.py +120 -0
- encommon-0.8.0/encommon/config/test/test_logger.py +259 -0
- encommon-0.8.0/encommon/config/test/test_paths.py +138 -0
- encommon-0.8.0/encommon/conftest.py +84 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/crypts/__init__.py +2 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/crypts/crypts.py +3 -1
- {encommon-0.7.5 → encommon-0.8.0}/encommon/crypts/hashes.py +2 -2
- {encommon-0.7.5 → encommon-0.8.0}/encommon/crypts/test/test_crypts.py +50 -28
- encommon-0.8.0/encommon/crypts/test/test_hashes.py +55 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/__init__.py +2 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/common.py +99 -15
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/duration.py +50 -36
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/parse.py +13 -25
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/test/test_common.py +47 -16
- encommon-0.8.0/encommon/times/test/test_duration.py +202 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/test/test_parse.py +53 -63
- encommon-0.8.0/encommon/times/test/test_timers.py +173 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/test/test_times.py +21 -30
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/test/test_window.py +73 -21
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/timers.py +91 -58
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/times.py +36 -34
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/dicts.py +10 -4
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/empty.py +7 -2
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/strings.py +10 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/test/test_dicts.py +5 -5
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/test/test_empty.py +4 -1
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/test/test_strings.py +1 -1
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/__init__.py +4 -0
- encommon-0.8.0/encommon/utils/common.py +72 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/match.py +1 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/paths.py +42 -23
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/sample.py +30 -26
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/stdout.py +28 -17
- encommon-0.8.0/encommon/utils/test/test_common.py +35 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/test/test_paths.py +3 -2
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/test/test_sample.py +28 -12
- encommon-0.8.0/encommon/version.txt +1 -0
- {encommon-0.7.5 → encommon-0.8.0/encommon.egg-info}/PKG-INFO +1 -1
- {encommon-0.7.5 → encommon-0.8.0}/encommon.egg-info/SOURCES.txt +1 -0
- {encommon-0.7.5 → encommon-0.8.0}/setup.cfg +4 -1
- encommon-0.7.5/encommon/config/test/test_config.py +0 -151
- encommon-0.7.5/encommon/config/test/test_files.py +0 -105
- encommon-0.7.5/encommon/config/test/test_logger.py +0 -212
- encommon-0.7.5/encommon/config/test/test_paths.py +0 -98
- encommon-0.7.5/encommon/conftest.py +0 -44
- encommon-0.7.5/encommon/crypts/test/test_hashes.py +0 -53
- encommon-0.7.5/encommon/times/test/test_duration.py +0 -177
- encommon-0.7.5/encommon/times/test/test_timers.py +0 -119
- encommon-0.7.5/encommon/utils/common.py +0 -27
- encommon-0.7.5/encommon/version.txt +0 -1
- {encommon-0.7.5 → encommon-0.8.0}/LICENSE +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/MANIFEST.in +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/README.md +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/config/test/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/crypts/params.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/crypts/test/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/py.typed +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/test/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/times/window.py +4 -4
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/types/test/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/test/__init__.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/test/test_match.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon/utils/test/test_stdout.py +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon.egg-info/dependency_links.txt +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon.egg-info/requires.txt +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/encommon.egg-info/top_level.txt +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/pyproject.toml +0 -0
- {encommon-0.7.5 → encommon-0.8.0}/reqs-install.txt +0 -0
@@ -14,6 +14,8 @@ from .config import Config
|
|
14
14
|
from .files import ConfigFile
|
15
15
|
from .files import ConfigFiles
|
16
16
|
from .logger import Logger
|
17
|
+
from .params import ConfigParams
|
18
|
+
from .params import LoggerParams
|
17
19
|
from .params import Params
|
18
20
|
from .paths import ConfigPath
|
19
21
|
from .paths import ConfigPaths
|
@@ -24,9 +26,11 @@ __all__ = [
|
|
24
26
|
'Config',
|
25
27
|
'ConfigFile',
|
26
28
|
'ConfigFiles',
|
29
|
+
'ConfigParams',
|
27
30
|
'ConfigPath',
|
28
31
|
'ConfigPaths',
|
29
32
|
'Logger',
|
33
|
+
'LoggerParams',
|
30
34
|
'Params',
|
31
35
|
'config_load',
|
32
36
|
'config_path',
|
@@ -11,15 +11,20 @@ from pathlib import Path
|
|
11
11
|
from typing import Any
|
12
12
|
from typing import Literal
|
13
13
|
from typing import Optional
|
14
|
+
from typing import TYPE_CHECKING
|
14
15
|
|
15
16
|
from yaml import SafeLoader
|
16
17
|
from yaml import load
|
17
18
|
|
18
19
|
from .. import PROJECT
|
19
20
|
from .. import WORKSPACE
|
20
|
-
from ..utils
|
21
|
-
from ..utils
|
22
|
-
from ..utils
|
21
|
+
from ..utils import read_text
|
22
|
+
from ..utils import resolve_path
|
23
|
+
from ..utils import resolve_paths
|
24
|
+
|
25
|
+
if TYPE_CHECKING:
|
26
|
+
from ..utils.common import PATHABLE
|
27
|
+
from ..utils.common import REPLACE
|
23
28
|
|
24
29
|
|
25
30
|
|
@@ -42,9 +47,8 @@ def config_load(
|
|
42
47
|
:returns: New resolved filesystem path object instance.
|
43
48
|
"""
|
44
49
|
|
45
|
-
loaded = (
|
46
|
-
config_path(path)
|
47
|
-
.read_text(encoding='utf-8'))
|
50
|
+
loaded = read_text(
|
51
|
+
config_path(path))
|
48
52
|
|
49
53
|
parsed = load(loaded, SafeLoader)
|
50
54
|
|
@@ -58,7 +62,7 @@ def config_path(
|
|
58
62
|
path: str | Path,
|
59
63
|
) -> Path:
|
60
64
|
"""
|
61
|
-
Resolve the provided path
|
65
|
+
Resolve the provided path replacing the magic keywords.
|
62
66
|
|
63
67
|
.. note::
|
64
68
|
This function simply wraps one from utils subpackage.
|
@@ -68,19 +72,19 @@ def config_path(
|
|
68
72
|
"""
|
69
73
|
|
70
74
|
replace = {
|
71
|
-
'PROJECT':
|
72
|
-
'WORKSPACE':
|
75
|
+
'PROJECT': PROJECT,
|
76
|
+
'WORKSPACE': WORKSPACE}
|
73
77
|
|
74
78
|
return resolve_path(path, replace)
|
75
79
|
|
76
80
|
|
77
81
|
|
78
82
|
def config_paths(
|
79
|
-
paths: PATHABLE,
|
80
|
-
replace: Optional[
|
83
|
+
paths: 'PATHABLE',
|
84
|
+
replace: Optional['REPLACE'] = None,
|
81
85
|
) -> tuple[Path, ...]:
|
82
86
|
"""
|
83
|
-
Resolve the provided paths
|
87
|
+
Resolve the provided paths replacing the magic keywords.
|
84
88
|
|
85
89
|
.. note::
|
86
90
|
This function simply wraps one from utils subpackage.
|
@@ -90,7 +94,7 @@ def config_paths(
|
|
90
94
|
"""
|
91
95
|
|
92
96
|
replace = {
|
93
|
-
'PROJECT':
|
94
|
-
'WORKSPACE':
|
97
|
+
'PROJECT': PROJECT,
|
98
|
+
'WORKSPACE': WORKSPACE}
|
95
99
|
|
96
100
|
return resolve_paths(paths, replace)
|
@@ -11,15 +11,18 @@ from copy import deepcopy
|
|
11
11
|
from typing import Any
|
12
12
|
from typing import Callable
|
13
13
|
from typing import Optional
|
14
|
+
from typing import TYPE_CHECKING
|
14
15
|
|
15
16
|
from .common import config_paths
|
16
17
|
from .files import ConfigFiles
|
17
18
|
from .logger import Logger
|
18
19
|
from .params import Params
|
19
20
|
from .paths import ConfigPaths
|
20
|
-
from ..crypts
|
21
|
-
from ..types
|
22
|
-
|
21
|
+
from ..crypts import Crypts
|
22
|
+
from ..types import merge_dicts
|
23
|
+
|
24
|
+
if TYPE_CHECKING:
|
25
|
+
from ..utils.common import PATHABLE
|
23
26
|
|
24
27
|
|
25
28
|
|
@@ -52,8 +55,8 @@ class Config:
|
|
52
55
|
def __init__(
|
53
56
|
self,
|
54
57
|
*,
|
55
|
-
files: Optional[PATHABLE] = None,
|
56
|
-
paths: Optional[PATHABLE] = None,
|
58
|
+
files: Optional['PATHABLE'] = None,
|
59
|
+
paths: Optional['PATHABLE'] = None,
|
57
60
|
cargs: Optional[dict[str, Any]] = None,
|
58
61
|
model: Optional[Callable] = None, # type: ignore
|
59
62
|
) -> None:
|
@@ -11,12 +11,15 @@ from copy import deepcopy
|
|
11
11
|
from pathlib import Path
|
12
12
|
from typing import Any
|
13
13
|
from typing import Optional
|
14
|
+
from typing import TYPE_CHECKING
|
14
15
|
|
15
16
|
from .common import config_load
|
16
17
|
from .common import config_path
|
17
18
|
from .common import config_paths
|
18
19
|
from ..types import merge_dicts
|
19
|
-
|
20
|
+
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
from ..utils.common import PATHABLE
|
20
23
|
|
21
24
|
|
22
25
|
|
@@ -63,7 +66,7 @@ class ConfigFiles:
|
|
63
66
|
|
64
67
|
def __init__(
|
65
68
|
self,
|
66
|
-
paths: PATHABLE,
|
69
|
+
paths: 'PATHABLE',
|
67
70
|
force: bool = False,
|
68
71
|
) -> None:
|
69
72
|
"""
|
@@ -89,13 +92,16 @@ class ConfigFiles:
|
|
89
92
|
:returns: Configuration in dictionary format for files.
|
90
93
|
"""
|
91
94
|
|
92
|
-
|
93
|
-
|
95
|
+
config = self.config
|
96
|
+
merged = self.__merged
|
97
|
+
|
98
|
+
if merged is not None:
|
99
|
+
return deepcopy(merged)
|
94
100
|
|
95
|
-
merged
|
101
|
+
merged = {}
|
96
102
|
|
97
103
|
|
98
|
-
for
|
104
|
+
for file in config.values():
|
99
105
|
|
100
106
|
source = file.config
|
101
107
|
|
@@ -107,4 +113,4 @@ class ConfigFiles:
|
|
107
113
|
|
108
114
|
self.__merged = merged
|
109
115
|
|
110
|
-
return deepcopy(
|
116
|
+
return deepcopy(merged)
|
@@ -28,18 +28,22 @@ from typing import TYPE_CHECKING
|
|
28
28
|
|
29
29
|
from .common import LOGLEVELS
|
30
30
|
from .common import config_path
|
31
|
-
from ..times
|
32
|
-
from ..
|
33
|
-
from ..types.
|
34
|
-
from ..
|
31
|
+
from ..times import Times
|
32
|
+
from ..types import Empty
|
33
|
+
from ..types.strings import COMMAD
|
34
|
+
from ..types.strings import COMMAS
|
35
|
+
from ..types.strings import SPACED
|
36
|
+
from ..utils import kvpair_ansi
|
37
|
+
from ..utils.common import JOINABLE
|
35
38
|
|
36
39
|
if TYPE_CHECKING:
|
37
40
|
from .params import LoggerParams
|
41
|
+
from ..times.common import PARSABLE
|
38
42
|
|
39
43
|
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
LOGR_FILE = 'encommon.logger.file'
|
46
|
+
LOGR_STDO = 'encommon.logger.stdo'
|
43
47
|
|
44
48
|
LOGSEVERS = {
|
45
49
|
'critical': int(CRITICAL),
|
@@ -79,7 +83,7 @@ class Message:
|
|
79
83
|
def __init__(
|
80
84
|
self,
|
81
85
|
level: LOGLEVELS,
|
82
|
-
time: Optional[PARSABLE] = None,
|
86
|
+
time: Optional['PARSABLE'] = None,
|
83
87
|
**kwargs: Any,
|
84
88
|
) -> None:
|
85
89
|
"""
|
@@ -90,7 +94,10 @@ class Message:
|
|
90
94
|
self.__time = Times(time)
|
91
95
|
self.__fields = {}
|
92
96
|
|
93
|
-
|
97
|
+
items = kwargs.items()
|
98
|
+
|
99
|
+
for key, value in items:
|
100
|
+
|
94
101
|
|
95
102
|
if (hasattr(value, '__len__')
|
96
103
|
and not len(value)):
|
@@ -99,10 +106,21 @@ class Message:
|
|
99
106
|
if value in [None, Empty]:
|
100
107
|
continue
|
101
108
|
|
102
|
-
|
103
|
-
|
109
|
+
|
110
|
+
if isinstance(value, JOINABLE):
|
111
|
+
|
112
|
+
values = sorted(
|
113
|
+
str(x) for x in value)
|
114
|
+
|
115
|
+
value = COMMAD.join(values)
|
116
|
+
|
117
|
+
|
118
|
+
if (isinstance(value, float)
|
119
|
+
and key == 'elapsed'):
|
120
|
+
|
104
121
|
value = round(value, 2)
|
105
122
|
|
123
|
+
|
106
124
|
value = str(value)
|
107
125
|
|
108
126
|
self.__fields[key] = value
|
@@ -123,7 +141,7 @@ class Message:
|
|
123
141
|
|
124
142
|
fields |= dict(self.__fields)
|
125
143
|
|
126
|
-
message =
|
144
|
+
message = COMMAS.join([
|
127
145
|
f'{k}="{v}"' for k, v
|
128
146
|
in fields.items()])
|
129
147
|
|
@@ -205,11 +223,16 @@ class Message:
|
|
205
223
|
|
206
224
|
output: list[str] = []
|
207
225
|
|
208
|
-
|
209
|
-
|
210
|
-
|
226
|
+
items = fields.items()
|
227
|
+
|
228
|
+
for field, value in items:
|
229
|
+
|
230
|
+
_value = kvpair_ansi(
|
231
|
+
field, value)
|
232
|
+
|
233
|
+
output.append(_value)
|
211
234
|
|
212
|
-
return
|
235
|
+
return SPACED.join(output)
|
213
236
|
|
214
237
|
|
215
238
|
@property
|
@@ -235,7 +258,7 @@ class Message:
|
|
235
258
|
|
236
259
|
class FileFormatter(Formatter):
|
237
260
|
"""
|
238
|
-
Supplement class for built-in
|
261
|
+
Supplement class for built-in logger exception formatter.
|
239
262
|
"""
|
240
263
|
|
241
264
|
|
@@ -299,8 +322,8 @@ class Logger:
|
|
299
322
|
|
300
323
|
__started: bool
|
301
324
|
|
302
|
-
|
303
|
-
|
325
|
+
__logr_stdo: _Logger
|
326
|
+
__logr_file: _Logger
|
304
327
|
|
305
328
|
|
306
329
|
def __init__(
|
@@ -329,8 +352,11 @@ class Logger:
|
|
329
352
|
|
330
353
|
self.__started = False
|
331
354
|
|
332
|
-
|
333
|
-
|
355
|
+
logr_stdo = getLogger(LOGR_STDO)
|
356
|
+
logr_file = getLogger(LOGR_FILE)
|
357
|
+
|
358
|
+
self.__logr_stdo = logr_stdo
|
359
|
+
self.__logr_file = logr_file
|
334
360
|
|
335
361
|
|
336
362
|
@property
|
@@ -395,7 +421,7 @@ class Logger:
|
|
395
421
|
:returns: Value for the attribute from class instance.
|
396
422
|
"""
|
397
423
|
|
398
|
-
return self.
|
424
|
+
return self.__logr_stdo
|
399
425
|
|
400
426
|
|
401
427
|
@property
|
@@ -408,7 +434,7 @@ class Logger:
|
|
408
434
|
:returns: Value for the attribute from class instance.
|
409
435
|
"""
|
410
436
|
|
411
|
-
return self.
|
437
|
+
return self.__logr_file
|
412
438
|
|
413
439
|
|
414
440
|
def start(
|
@@ -422,39 +448,47 @@ class Logger:
|
|
422
448
|
file_level = self.__file_level
|
423
449
|
file_path = self.__file_path
|
424
450
|
|
425
|
-
|
426
|
-
|
451
|
+
logr_stdo = self.__logr_stdo
|
452
|
+
logr_file = self.__logr_file
|
453
|
+
|
427
454
|
|
455
|
+
logr_root = getLogger()
|
428
456
|
|
429
|
-
|
430
|
-
logger_root.setLevel(NOTSET)
|
457
|
+
logr_root.setLevel(NOTSET)
|
431
458
|
|
432
|
-
|
433
|
-
|
459
|
+
logr_stdo.handlers = [NullHandler()]
|
460
|
+
logr_file.handlers = [NullHandler()]
|
434
461
|
|
435
462
|
|
436
463
|
if stdo_level is not None:
|
437
464
|
|
438
|
-
stdoh = StreamHandler()
|
439
|
-
format = Formatter('%(message)s')
|
440
465
|
level = LOGSEVERS[stdo_level]
|
441
466
|
|
442
|
-
|
443
|
-
|
467
|
+
handstdo = StreamHandler()
|
468
|
+
|
469
|
+
format = Formatter(
|
470
|
+
'%(message)s')
|
471
|
+
|
472
|
+
logr_stdo.handlers = [handstdo]
|
444
473
|
|
445
|
-
|
474
|
+
handstdo.setLevel(level)
|
475
|
+
handstdo.setFormatter(format)
|
446
476
|
|
447
477
|
|
448
478
|
if file_path and file_level:
|
449
479
|
|
450
|
-
fileh = FileHandler(file_path)
|
451
|
-
format = FileFormatter('%(message)s')
|
452
480
|
level = LOGSEVERS[file_level]
|
453
481
|
|
454
|
-
|
455
|
-
|
482
|
+
handfile = (
|
483
|
+
FileHandler(file_path))
|
456
484
|
|
457
|
-
|
485
|
+
format = FileFormatter(
|
486
|
+
'%(message)s')
|
487
|
+
|
488
|
+
logr_file.handlers = [handfile]
|
489
|
+
|
490
|
+
handfile.setLevel(level)
|
491
|
+
handfile.setFormatter(format)
|
458
492
|
|
459
493
|
|
460
494
|
self.__started = True
|
@@ -467,11 +501,11 @@ class Logger:
|
|
467
501
|
Deinitialize the Python logging library using parameters.
|
468
502
|
"""
|
469
503
|
|
470
|
-
|
471
|
-
|
504
|
+
logr_stdo = self.__logr_stdo
|
505
|
+
logr_file = self.__logr_file
|
472
506
|
|
473
|
-
|
474
|
-
|
507
|
+
logr_stdo.handlers = [NullHandler()]
|
508
|
+
logr_file.handlers = [NullHandler()]
|
475
509
|
|
476
510
|
self.__started = False
|
477
511
|
|
@@ -484,9 +518,9 @@ class Logger:
|
|
484
518
|
**kwargs: Any,
|
485
519
|
) -> None:
|
486
520
|
"""
|
487
|
-
Prepare keyword arguments and log to
|
521
|
+
Prepare keyword arguments and log to configured output.
|
488
522
|
|
489
|
-
:param exc_info: Optional exception
|
523
|
+
:param exc_info: Optional exception included with trace.
|
490
524
|
:param kwargs: Keyword arguments for populating message.
|
491
525
|
"""
|
492
526
|
|
@@ -497,19 +531,21 @@ class Logger:
|
|
497
531
|
file_level = self.__file_level
|
498
532
|
file_path = self.__file_path
|
499
533
|
|
500
|
-
|
501
|
-
|
534
|
+
logr_stdo = self.__logr_stdo
|
535
|
+
logr_file = self.__logr_file
|
502
536
|
|
503
537
|
message = Message(level, **kwargs)
|
504
538
|
|
505
539
|
if stdo_level is not None:
|
506
|
-
|
540
|
+
|
541
|
+
logr_stdo.log(
|
507
542
|
level=LOGSEVERS[level],
|
508
543
|
msg=message.stdo_output,
|
509
544
|
exc_info=exc_info)
|
510
545
|
|
511
546
|
if file_path and file_level:
|
512
|
-
|
547
|
+
|
548
|
+
logr_file.log(
|
513
549
|
level=LOGSEVERS[level],
|
514
550
|
msg=message.file_output,
|
515
551
|
exc_info=exc_info)
|
@@ -517,94 +553,64 @@ class Logger:
|
|
517
553
|
|
518
554
|
def log_c(
|
519
555
|
self,
|
520
|
-
*,
|
521
|
-
exc_info: Optional[Exception] = None,
|
522
556
|
**kwargs: Any,
|
523
557
|
) -> None:
|
524
558
|
"""
|
525
|
-
Prepare keyword arguments and log to
|
559
|
+
Prepare keyword arguments and log to configured output.
|
526
560
|
|
527
|
-
:param exc_info: Optional exception to include with trace.
|
528
561
|
:param kwargs: Keyword arguments for populating message.
|
529
562
|
"""
|
530
563
|
|
531
|
-
self.log(
|
532
|
-
level='critical',
|
533
|
-
exc_info=exc_info,
|
534
|
-
**kwargs)
|
564
|
+
self.log('critical', **kwargs)
|
535
565
|
|
536
566
|
|
537
567
|
def log_d(
|
538
568
|
self,
|
539
|
-
*,
|
540
|
-
exc_info: Optional[Exception] = None,
|
541
569
|
**kwargs: Any,
|
542
570
|
) -> None:
|
543
571
|
"""
|
544
|
-
Prepare keyword arguments and log to
|
572
|
+
Prepare keyword arguments and log to configured output.
|
545
573
|
|
546
|
-
:param exc_info: Optional exception to include with trace.
|
547
574
|
:param kwargs: Keyword arguments for populating message.
|
548
575
|
"""
|
549
576
|
|
550
|
-
self.log(
|
551
|
-
level='debug',
|
552
|
-
exc_info=exc_info,
|
553
|
-
**kwargs)
|
577
|
+
self.log('debug', **kwargs)
|
554
578
|
|
555
579
|
|
556
580
|
def log_e(
|
557
581
|
self,
|
558
|
-
*,
|
559
|
-
exc_info: Optional[Exception] = None,
|
560
582
|
**kwargs: Any,
|
561
583
|
) -> None:
|
562
584
|
"""
|
563
|
-
Prepare keyword arguments and log to
|
585
|
+
Prepare keyword arguments and log to configured output.
|
564
586
|
|
565
|
-
:param exc_info: Optional exception to include with trace.
|
566
587
|
:param kwargs: Keyword arguments for populating message.
|
567
588
|
"""
|
568
589
|
|
569
|
-
self.log(
|
570
|
-
level='error',
|
571
|
-
exc_info=exc_info,
|
572
|
-
**kwargs)
|
590
|
+
self.log('error', **kwargs)
|
573
591
|
|
574
592
|
|
575
593
|
def log_i(
|
576
594
|
self,
|
577
|
-
*,
|
578
|
-
exc_info: Optional[Exception] = None,
|
579
595
|
**kwargs: Any,
|
580
596
|
) -> None:
|
581
597
|
"""
|
582
|
-
Prepare keyword arguments and log to
|
598
|
+
Prepare keyword arguments and log to configured output.
|
583
599
|
|
584
|
-
:param exc_info: Optional exception to include with trace.
|
585
600
|
:param kwargs: Keyword arguments for populating message.
|
586
601
|
"""
|
587
602
|
|
588
|
-
self.log(
|
589
|
-
level='info',
|
590
|
-
exc_info=exc_info,
|
591
|
-
**kwargs)
|
603
|
+
self.log('info', **kwargs)
|
592
604
|
|
593
605
|
|
594
606
|
def log_w(
|
595
607
|
self,
|
596
|
-
*,
|
597
|
-
exc_info: Optional[Exception] = None,
|
598
608
|
**kwargs: Any,
|
599
609
|
) -> None:
|
600
610
|
"""
|
601
|
-
Prepare keyword arguments and log to
|
611
|
+
Prepare keyword arguments and log to configured output.
|
602
612
|
|
603
|
-
:param exc_info: Optional exception to include with trace.
|
604
613
|
:param kwargs: Keyword arguments for populating message.
|
605
614
|
"""
|
606
615
|
|
607
|
-
self.log(
|
608
|
-
level='warning',
|
609
|
-
exc_info=exc_info,
|
610
|
-
**kwargs)
|
616
|
+
self.log('warning', **kwargs)
|
@@ -12,11 +12,14 @@ from glob import glob
|
|
12
12
|
from pathlib import Path
|
13
13
|
from typing import Any
|
14
14
|
from typing import Optional
|
15
|
+
from typing import TYPE_CHECKING
|
15
16
|
|
16
17
|
from .common import config_path
|
17
18
|
from .common import config_paths
|
18
19
|
from .files import ConfigFile
|
19
|
-
|
20
|
+
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
from ..utils.common import PATHABLE
|
20
23
|
|
21
24
|
|
22
25
|
|
@@ -71,7 +74,7 @@ class ConfigPaths:
|
|
71
74
|
|
72
75
|
def __init__(
|
73
76
|
self,
|
74
|
-
paths: PATHABLE,
|
77
|
+
paths: 'PATHABLE',
|
75
78
|
force: bool = False,
|
76
79
|
) -> None:
|
77
80
|
"""
|
@@ -97,19 +100,24 @@ class ConfigPaths:
|
|
97
100
|
:returns: Configuration in dictionary format for paths.
|
98
101
|
"""
|
99
102
|
|
100
|
-
|
101
|
-
|
103
|
+
config = self.config
|
104
|
+
merged = self.__merged
|
105
|
+
|
106
|
+
if merged is not None:
|
107
|
+
return deepcopy(merged)
|
108
|
+
|
109
|
+
merged = {}
|
102
110
|
|
103
|
-
merged: dict[str, Any] = {}
|
104
111
|
|
112
|
+
for path in config.values():
|
105
113
|
|
106
|
-
|
114
|
+
items = path.config.items()
|
107
115
|
|
108
|
-
for key, file in
|
116
|
+
for key, file in items:
|
109
117
|
|
110
118
|
merged[key] = file.config
|
111
119
|
|
112
120
|
|
113
121
|
self.__merged = merged
|
114
122
|
|
115
|
-
return deepcopy(
|
123
|
+
return deepcopy(merged)
|
@@ -9,6 +9,7 @@ is permitted, for more information consult the project license file.
|
|
9
9
|
|
10
10
|
from ..common import config_load
|
11
11
|
from ..common import config_path
|
12
|
+
from ..common import config_paths
|
12
13
|
from ... import PROJECT
|
13
14
|
from ... import WORKSPACE
|
14
15
|
|
@@ -19,9 +20,11 @@ def test_config_load() -> None:
|
|
19
20
|
Perform various tests associated with relevant routines.
|
20
21
|
"""
|
21
22
|
|
22
|
-
|
23
|
+
loaded = config_load(
|
24
|
+
'PROJECT/../.yamllint')
|
23
25
|
|
24
|
-
assert
|
26
|
+
assert list(loaded) == [
|
27
|
+
'extends', 'rules']
|
25
28
|
|
26
29
|
|
27
30
|
|
@@ -30,5 +33,25 @@ def test_config_path() -> None:
|
|
30
33
|
Perform various tests associated with relevant routines.
|
31
34
|
"""
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
|
37
|
+
path = config_path('PROJECT')
|
38
|
+
|
39
|
+
assert path == PROJECT
|
40
|
+
|
41
|
+
|
42
|
+
path = config_path('WORKSPACE')
|
43
|
+
|
44
|
+
assert path == WORKSPACE
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
def test_config_paths() -> None:
|
49
|
+
"""
|
50
|
+
Perform various tests associated with relevant routines.
|
51
|
+
"""
|
52
|
+
|
53
|
+
paths = config_paths([
|
54
|
+
'PROJECT', 'WORKSPACE'])
|
55
|
+
|
56
|
+
assert paths == (
|
57
|
+
PROJECT, WORKSPACE)
|