encommon 0.4.1__py3-none-any.whl → 0.5.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/params.py CHANGED
@@ -20,7 +20,9 @@ class ConfigParams(BaseModel, extra='forbid'):
20
20
  """
21
21
  Process and validate the common configuration parameters.
22
22
 
23
+ :param paths: Complete or relative path to config paths.
23
24
  :param data: Keyword arguments passed to Pydantic model.
25
+ This parameter is picked up by autodoc, please ignore.
24
26
  """
25
27
 
26
28
  paths: Optional[list[str]] = None
@@ -31,7 +33,11 @@ class LoggerParams(BaseModel, extra='forbid'):
31
33
  """
32
34
  Process and validate the common configuration parameters.
33
35
 
36
+ :param stdo_level: Minimum log message severity level.
37
+ :param file_level: Minimum log message severity level.
38
+ :param file_path: Enables writing to the filesystem path.
34
39
  :param data: Keyword arguments passed to Pydantic model.
40
+ This parameter is picked up by autodoc, please ignore.
35
41
  """
36
42
 
37
43
  stdo_level: Optional[LOGLEVELS] = None
@@ -44,7 +50,11 @@ class Params(BaseModel, extra='forbid'):
44
50
  """
45
51
  Process and validate the common configuration parameters.
46
52
 
53
+ :param enconfig: Configuration for the `.Config` object.
54
+ :param enlogger: Configuration for the `.Logger` object.
55
+ :param encrypts: Configuration for the `.Crypts` object.
47
56
  :param data: Keyword arguments passed to Pydantic model.
57
+ This parameter is picked up by autodoc, please ignore.
48
58
  """
49
59
 
50
60
  enconfig: Optional[ConfigParams] = None
@@ -25,7 +25,7 @@ SAMPLES = (
25
25
 
26
26
 
27
27
 
28
- def test_Config(
28
+ def test_Config( # noqa: CFQ001
29
29
  config_path: Path,
30
30
  ) -> None:
31
31
  """
@@ -108,6 +108,26 @@ def test_Config(
108
108
  assert sample == expect
109
109
 
110
110
 
111
+ _params1 = config.params
112
+ _params2 = config.params
113
+
114
+ assert _params1 is _params2
115
+
116
+ sample = load_sample(
117
+ path=SAMPLES.joinpath('params.json'),
118
+ update=ENPYRWS,
119
+ content=_params1.model_dump(),
120
+ replace={
121
+ 'config_path': str(config_path)})
122
+
123
+ expect = prep_sample(
124
+ content=_params2.model_dump(),
125
+ replace={
126
+ 'config_path': str(config_path)})
127
+
128
+ assert sample == expect
129
+
130
+
111
131
  logger = config.logger
112
132
 
113
133
  assert isinstance(logger, Logger)
encommon/times/common.py CHANGED
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
20
20
 
21
21
 
22
22
  NUMERISH = compile(r'^\-?\d+(\.\d+)?$')
23
- SNAPABLE = compile(r'^\-|\+[\d\@a-z]+$')
23
+ SNAPABLE = compile(r'^(\-|\+)[\d\@a-z\-\+]+$')
24
24
  STRINGNOW = {'None', 'null', 'now'}
25
25
 
26
26
  NUMERIC = Union[int, float]
encommon/times/timers.py CHANGED
@@ -130,8 +130,8 @@ class Timers:
130
130
  Update the existing timer from mapping within the cache.
131
131
 
132
132
  :param unique: Unique identifier for the timer in mapping.
133
- :param started: Determines when the time starts for timer.
134
133
  :param minimum: Determines minimum seconds that must pass.
134
+ :param started: Determines when the time starts for timer.
135
135
  """
136
136
 
137
137
  timer = self.__timing
@@ -8,10 +8,14 @@ is permitted, for more information consult the project license file.
8
8
 
9
9
 
10
10
  from .dicts import merge_dicts
11
+ from .dicts import sort_dict
11
12
  from .empty import Empty
13
+ from .strings import striplower
12
14
 
13
15
 
14
16
 
15
17
  __all__ = [
16
18
  'Empty',
17
- 'merge_dicts']
19
+ 'merge_dicts',
20
+ 'sort_dict',
21
+ 'striplower']
encommon/types/dicts.py CHANGED
@@ -58,3 +58,29 @@ def merge_dicts(
58
58
 
59
59
  elif force is True:
60
60
  dict1[key] = value
61
+
62
+
63
+
64
+ def sort_dict(
65
+ value: dict[Any, Any],
66
+ reverse: bool = False,
67
+ ) -> dict[Any, Any]:
68
+ """
69
+ Sort the keys within the dictionary and return new one.
70
+
71
+ Example
72
+ -------
73
+ >>> foo = {'b': 'be', 'a': 'ey'}
74
+ >>> sort_dict(foo)
75
+ {'a': 'ey', 'b': 'be'}
76
+ >>> sort_dict(foo, True)
77
+ {'b': 'be', 'a': 'ey'}
78
+
79
+ :param value: Dictionary whose keys are sorted into new.
80
+ :param reverse: Optionally reverse the sort direction.
81
+ :returns: New dictionary with keys sorted alphabetical.
82
+ """
83
+
84
+ return dict(sorted(
85
+ value.items(),
86
+ reverse=reverse))
@@ -0,0 +1,25 @@
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
+ def striplower(
11
+ value: str,
12
+ ) -> str:
13
+ """
14
+ Return the provided string but stripped and lower cased.
15
+
16
+ Example
17
+ -------
18
+ >>> striplower(' Foo ')
19
+ 'foo'
20
+
21
+ :param value: String which will be stripped and lowered.
22
+ :returns: Provided string but stripped and lower cased.
23
+ """
24
+
25
+ return value.strip().lower()
@@ -10,6 +10,23 @@ is permitted, for more information consult the project license file.
10
10
  from copy import deepcopy
11
11
 
12
12
  from ..dicts import merge_dicts
13
+ from ..dicts import sort_dict
14
+
15
+
16
+
17
+ DICT1 = {
18
+ 'dict1': 'dict1',
19
+ 'str': 'd1string',
20
+ 'list': ['d1list'],
21
+ 'dict': {'key': 'd1value'},
22
+ 'bool': False}
23
+
24
+ DICT2 = {
25
+ 'dict2': 'dict2',
26
+ 'str': 'd2string',
27
+ 'list': ['d2list'],
28
+ 'dict': {'key': 'd2value'},
29
+ 'bool': True}
13
30
 
14
31
 
15
32
 
@@ -18,19 +35,8 @@ def test_merge_dicts() -> None:
18
35
  Perform various tests associated with relevant routines.
19
36
  """
20
37
 
21
- dict1 = {
22
- 'dict1': 'dict1',
23
- 'str': 'd1string',
24
- 'list': ['d1list'],
25
- 'dict': {'key': 'd1value'},
26
- 'bool': False}
27
-
28
- dict2 = {
29
- 'dict2': 'dict2',
30
- 'str': 'd2string',
31
- 'list': ['d2list'],
32
- 'dict': {'key': 'd2value'},
33
- 'bool': True}
38
+ dict1 = deepcopy(DICT1)
39
+ dict2 = deepcopy(DICT2)
34
40
 
35
41
  dict1['recurse'] = deepcopy(dict1)
36
42
  dict2['recurse'] = deepcopy(dict2)
@@ -100,3 +106,17 @@ def test_merge_dicts() -> None:
100
106
  'list': ['d1list'],
101
107
  'dict': {'key': 'd1value'},
102
108
  'bool': False}}
109
+
110
+
111
+
112
+ def test_sort_dict() -> None:
113
+ """
114
+ Perform various tests associated with relevant routines.
115
+ """
116
+
117
+ assert sort_dict(DICT1) == {
118
+ 'bool': False,
119
+ 'dict': {'key': 'd1value'},
120
+ 'dict1': 'dict1',
121
+ 'list': ['d1list'],
122
+ 'str': 'd1string'}
@@ -0,0 +1,19 @@
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 ..strings import striplower
11
+
12
+
13
+
14
+ def test_striplower() -> None:
15
+ """
16
+ Perform various tests associated with relevant routines.
17
+ """
18
+
19
+ assert striplower(' Foo ') == 'foo'
encommon/utils/sample.py CHANGED
@@ -98,7 +98,7 @@ def load_sample(
98
98
  :param update: Determine whether the sample is updated.
99
99
  :param content: Content which will be processed for JSON.
100
100
  :param default: Callable used when stringifying values.
101
- :param replace: Optional string values to replace in path.
101
+ :param replace: Optional string values to replace in file.
102
102
  :returns: Content after processing using JSON functions.
103
103
  """
104
104
 
encommon/version.txt CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Enasis Network
3
+ Copyright (c) 2024 Enasis Network
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: encommon
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Classifier: Programming Language :: Python :: 3
@@ -18,14 +18,15 @@ Requires-Dist: snaptime
18
18
 
19
19
  # Enasis Network Common Library
20
20
 
21
- [![](https://img.shields.io/github/actions/workflow/status/enasisnetwork/encommon/build.yml?style=flat-square&label=GitHub%20actions)](https://github.com/enasisnetwork/encommon/actions)
22
- [![](https://img.shields.io/readthedocs/encommon?style=flat-square&label=Read%20the%20Docs)](https://encommon.readthedocs.io/en/stable)
23
- [![](https://img.shields.io/pypi/v/encommon.svg?style=flat-square&label=PyPi%20version)](https://pypi.org/project/encommon)
24
- [![](https://img.shields.io/pypi/dm/encommon?style=flat-square&label=PyPi%20downloads)](https://pypi.org/project/encommon)
25
-
26
21
  Common classes and functions used in various public and private projects for
27
22
  [Enasis Network](https://github.com/enasisnetwork).
28
23
 
24
+ [![](https://img.shields.io/github/actions/workflow/status/enasisnetwork/encommon/build.yml?style=flat-square&label=GitHub%20actions)](https://github.com/enasisnetwork/encommon/actions)<br>
25
+ [![codecov](https://codecov.io/gh/enasisnetwork/encommon/graph/badge.svg?token=7PGOXKJU0E)](https://codecov.io/gh/enasisnetwork/encommon)<br>
26
+ [![](https://img.shields.io/readthedocs/encommon?style=flat-square&label=Read%20the%20Docs)](https://encommon.readthedocs.io/en/stable)<br>
27
+ [![](https://img.shields.io/pypi/v/encommon.svg?style=flat-square&label=PyPi%20version)](https://pypi.org/project/encommon)<br>
28
+ [![](https://img.shields.io/pypi/dm/encommon?style=flat-square&label=PyPi%20downloads)](https://pypi.org/project/encommon)
29
+
29
30
  ## Installing the package
30
31
  Installing stable from the PyPi repository
31
32
  ```
@@ -1,17 +1,17 @@
1
1
  encommon/__init__.py,sha256=VoXUcphq-gcXCraaU47EtXBftF6UVuQPMGr0fuCTt9A,525
2
+ encommon/conftest.py,sha256=TNLox448WJSUkG5Lx2PM7LWvLHiaaOvxm6tx6o02pBc,810
2
3
  encommon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- encommon/version.txt,sha256=9iGEzuh4fy9pQcggQaVyXU7cmqKT6-Xb9mRAboLsH-E,6
4
+ encommon/version.txt,sha256=oK1QZAE5pST4ZZEVcUW_HUZ06pwGW_6iFVjw97BEMMg,6
4
5
  encommon/config/__init__.py,sha256=2ic7tK2lOQvqWmmQnMozqxCJcbyQ_sSEHmOUDUFan2U,710
5
6
  encommon/config/common.py,sha256=gaKBgkF7b7UIAhd0ESio0KpG8JfdRpz5BxNgKRptd6A,2041
6
7
  encommon/config/config.py,sha256=pvvz5lzqaXJV-9-8v8XPXVP8vpHiZ9lzGLx05pjW5gk,4855
7
8
  encommon/config/files.py,sha256=2DHz7GKOjF8FC26tY0V-E9svNMrlkSUshb2gfxqGgSo,2313
8
9
  encommon/config/logger.py,sha256=2y-VFzgM2pZzEYq48XfvrDPrtUcxyP9QjbH5OG7fv5o,13449
9
- encommon/config/params.py,sha256=8urH47NIIspO5MGkXdOuLRzWpmNqMnKXSagNeiIwkHw,1212
10
+ encommon/config/params.py,sha256=IWQ-UzR8x6VxkcUddC3qhI612IFMfLW44jEjRePXK0c,1825
10
11
  encommon/config/paths.py,sha256=0EpXWn6G9IO6tuZTrWuDq53RI5xMTgDQrAlOjRLILHs,2433
11
12
  encommon/config/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
12
- encommon/config/test/conftest.py,sha256=TNLox448WJSUkG5Lx2PM7LWvLHiaaOvxm6tx6o02pBc,810
13
13
  encommon/config/test/test_common.py,sha256=U6XWfCLxtLmArn8P6h4cmCALzdXxV7IMUxKNU-UhwPw,731
14
- encommon/config/test/test_config.py,sha256=k67kmzoRhakkrB_5xmN-VrLXuELCH4k5ZUHQySxtu_s,2824
14
+ encommon/config/test/test_config.py,sha256=SMe8ZrHRVS7jcyoFB-jBmlYTdUkBT1RrjZ9QlAW1EtE,3292
15
15
  encommon/config/test/test_files.py,sha256=OlGziUPV35yrdn2Ac8tuqmFfjHciWJADdQRvacoJNUc,2298
16
16
  encommon/config/test/test_logger.py,sha256=oLMosbxHq313oSNkdsrJe_kp0YrlcLCErIccg66zXcI,4635
17
17
  encommon/config/test/test_paths.py,sha256=vNWYqiN_wNuFCu1HHEekoJdGGJyRlucDBZTAspwxWhc,2107
@@ -23,10 +23,10 @@ encommon/crypts/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLE
23
23
  encommon/crypts/test/test_crypts.py,sha256=QDhIUVzn-n5z9tk1ZPXbZ4pBx0CRtcfqIyESYVB0kbU,2433
24
24
  encommon/crypts/test/test_hashes.py,sha256=Spixpx2qBi6iSJ8aNgmnNtz04JofUpwU-a_UjpRoiHA,1206
25
25
  encommon/times/__init__.py,sha256=w6LeTybgdsi0oM1EL9ARbAqevX7Tn46JYhbXNAaWzB0,597
26
- encommon/times/common.py,sha256=zDI5ztMkfLmV090jlLLK3hFzGGveasy8I_wNfOQDScg,2500
26
+ encommon/times/common.py,sha256=xLB_GLahYKT-YrVq90RUzmiodJQ4__1YihgZZTnadgg,2506
27
27
  encommon/times/duration.py,sha256=8p-L9OItO80nnd35FYrAXbiUS8RJzavI21lXBrtLaH0,9872
28
28
  encommon/times/parse.py,sha256=ZzranxftlB6bZJ1ivkoUxD53TUfXDDUdpq9jsSJN-88,6411
29
- encommon/times/timers.py,sha256=N9RrnHbNMzz7nlDEgJTmLq7u_93x61MT5Ku8EHmcMEU,3212
29
+ encommon/times/timers.py,sha256=4p2zJIieZZ8pMaKAv5CQdxUOPjVDd2f9QCpARB8gGnQ,3212
30
30
  encommon/times/times.py,sha256=Dfu6ztUsV4X4vHzOC7ds8jtYy0AVj4_R5xB6H-yzemE,9432
31
31
  encommon/times/window.py,sha256=Fx_OJfU9B0IctCyaJ5XH_HxzhGlzeRATwuhI-HlsTPA,8023
32
32
  encommon/times/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
@@ -36,25 +36,27 @@ encommon/times/test/test_parse.py,sha256=TuZG_UbIEez4Ww35vdKIie_yaKp-PiUhsNmr1ZU
36
36
  encommon/times/test/test_timers.py,sha256=F8asiUbMcIXkSstrOhQ9wrmdM2oTFAAM4sL50eQB4IA,1456
37
37
  encommon/times/test/test_times.py,sha256=DJBmRHCPkMLL9-bmc2DMhhf8zcr2rsTVAAQPavD_UmE,1986
38
38
  encommon/times/test/test_window.py,sha256=EWjXR8XREYwKrH-221CBAUwLF9GpvHtuF_CSMdQtUXI,4735
39
- encommon/types/__init__.py,sha256=zdSH4xILpR4FrkACwZ7Cu0Lu5F_YqltRJRhayQAcDGk,324
40
- encommon/types/dicts.py,sha256=76uxhJG7QEO1NViP8Kd_VAPBkcw2Wga1vgPh4ITKt7g,1616
39
+ encommon/types/__init__.py,sha256=l2WKtDs6uC9I3dIGnrzJvz-4JLEETUJOfT509XyMQWs,420
40
+ encommon/types/dicts.py,sha256=zJbfAsL1uiqfouBQrQgcYGoLowtkUd-Vm9536_DVK_E,2208
41
41
  encommon/types/empty.py,sha256=KrH6I0PPljaFBQ1qB1tbxFxZd8DR5rEFYhZqgLzjIsA,2675
42
+ encommon/types/strings.py,sha256=lgrzZuiCnH1UW17EFkLYiou3kQBgs_ZK2R92_dz7gRQ,560
42
43
  encommon/types/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
43
- encommon/types/test/test_dicts.py,sha256=BDuoh75UHeCRdV7lthLfhd8kku_E2Bjir_VeJoxldQM,2348
44
+ encommon/types/test/test_dicts.py,sha256=UHMvrWKnz-bPscq0Vp2uoLLFv4slvQQL2sobe5WUZ7U,2673
44
45
  encommon/types/test/test_empty.py,sha256=YUn0ROFhrWLQ30uROVqroHW4BsnFbzUZjACs3aEvrrI,981
46
+ encommon/types/test/test_strings.py,sha256=WHXf1dnK6Qs2_0UyGYztJxpS29bnR8WKjKsvVO2WCi4,407
45
47
  encommon/utils/__init__.py,sha256=qdr2RDKlmoGrgMhwJCaTrhQXmuD_lmDxlIxOUprnRVs,784
46
48
  encommon/utils/common.py,sha256=UrowELh3PtDzpSS48nGhsAxTS_QUk96-KEJa4MlxiMA,466
47
49
  encommon/utils/match.py,sha256=4L2d2Cvr7vp3odkRCdNQ10OIW8DkEP55_NbQ6bdsReo,2462
48
50
  encommon/utils/paths.py,sha256=4EeaPsVwpv3pzoHeWmiSSGYZEud6hkD27kvbvgSpOPs,3236
49
- encommon/utils/sample.py,sha256=Bm5PXKRc8JmgeQsvthoBHwU1yPkbnB8zS2piI7KWP4M,3169
51
+ encommon/utils/sample.py,sha256=hOhS6A2aB9a5kXfrst7gUSQkxuqEo2J1AFyBsJZQhHE,3169
50
52
  encommon/utils/stdout.py,sha256=0C5NTg8fAB25s5oKmsmV2VSERn22QFCZjqJ1S75SXOM,2779
51
53
  encommon/utils/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
52
54
  encommon/utils/test/test_match.py,sha256=QagKpTFdRo23-Y55fSaJrSMpt5jIebScKbz0h8tivrI,1124
53
55
  encommon/utils/test/test_paths.py,sha256=0ls9gWJ2B487Dr1fHDDFCZPA7gxtv56nFEYHrTkNX-U,1892
54
56
  encommon/utils/test/test_sample.py,sha256=iNV9IxXmA5KJat3jKRiZH3iutHrT6bsibwti60AhICk,1464
55
57
  encommon/utils/test/test_stdout.py,sha256=a060uA8oEHFGoVqdwB5iYxdl4R2TRSgr6Z7pMEbxibs,1675
56
- encommon-0.4.1.dist-info/LICENSE,sha256=04XJC5i4LRUf1A_U1EGCMJLpGodnmOFlh30yu7FAVfs,1071
57
- encommon-0.4.1.dist-info/METADATA,sha256=ymnId20TKS4QbdR_pEnplNsaj0_Tpql_tS4d3evYo9E,2517
58
- encommon-0.4.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
59
- encommon-0.4.1.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
60
- encommon-0.4.1.dist-info/RECORD,,
58
+ encommon-0.5.0.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
59
+ encommon-0.5.0.dist-info/METADATA,sha256=NJL3BwQ7cUm7Azf7NS1-ttm5v0ST4LW6G9tYD0NlIXA,2671
60
+ encommon-0.5.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
61
+ encommon-0.5.0.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
62
+ encommon-0.5.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes