encommon 0.4.1__tar.gz → 0.5.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.
Files changed (70) hide show
  1. {encommon-0.4.1 → encommon-0.5.0}/LICENSE +1 -1
  2. {encommon-0.4.1/encommon.egg-info → encommon-0.5.0}/PKG-INFO +7 -6
  3. {encommon-0.4.1 → encommon-0.5.0}/README.md +6 -5
  4. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/params.py +10 -0
  5. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/test/test_config.py +21 -1
  6. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/common.py +1 -1
  7. {encommon-0.4.1 → encommon-0.5.0}/encommon/types/__init__.py +5 -1
  8. {encommon-0.4.1 → encommon-0.5.0}/encommon/types/dicts.py +26 -0
  9. encommon-0.5.0/encommon/types/strings.py +25 -0
  10. {encommon-0.4.1 → encommon-0.5.0}/encommon/types/test/test_dicts.py +33 -13
  11. encommon-0.5.0/encommon/types/test/test_strings.py +19 -0
  12. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/sample.py +1 -1
  13. encommon-0.5.0/encommon/version.txt +1 -0
  14. {encommon-0.4.1 → encommon-0.5.0/encommon.egg-info}/PKG-INFO +7 -6
  15. {encommon-0.4.1 → encommon-0.5.0}/encommon.egg-info/SOURCES.txt +3 -1
  16. encommon-0.4.1/encommon/version.txt +0 -1
  17. {encommon-0.4.1 → encommon-0.5.0}/MANIFEST.in +0 -0
  18. {encommon-0.4.1 → encommon-0.5.0}/encommon/__init__.py +0 -0
  19. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/__init__.py +0 -0
  20. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/common.py +0 -0
  21. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/config.py +0 -0
  22. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/files.py +0 -0
  23. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/logger.py +0 -0
  24. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/paths.py +0 -0
  25. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/test/__init__.py +0 -0
  26. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/test/test_common.py +0 -0
  27. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/test/test_files.py +0 -0
  28. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/test/test_logger.py +0 -0
  29. {encommon-0.4.1 → encommon-0.5.0}/encommon/config/test/test_paths.py +0 -0
  30. {encommon-0.4.1/encommon/config/test → encommon-0.5.0/encommon}/conftest.py +0 -0
  31. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/__init__.py +0 -0
  32. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/crypts.py +0 -0
  33. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/hashes.py +0 -0
  34. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/params.py +0 -0
  35. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/test/__init__.py +0 -0
  36. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/test/test_crypts.py +0 -0
  37. {encommon-0.4.1 → encommon-0.5.0}/encommon/crypts/test/test_hashes.py +0 -0
  38. {encommon-0.4.1 → encommon-0.5.0}/encommon/py.typed +0 -0
  39. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/__init__.py +0 -0
  40. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/duration.py +0 -0
  41. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/parse.py +0 -0
  42. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/__init__.py +0 -0
  43. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/test_common.py +0 -0
  44. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/test_duration.py +0 -0
  45. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/test_parse.py +0 -0
  46. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/test_timers.py +0 -0
  47. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/test_times.py +0 -0
  48. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/test/test_window.py +0 -0
  49. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/timers.py +1 -1
  50. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/times.py +0 -0
  51. {encommon-0.4.1 → encommon-0.5.0}/encommon/times/window.py +0 -0
  52. {encommon-0.4.1 → encommon-0.5.0}/encommon/types/empty.py +0 -0
  53. {encommon-0.4.1 → encommon-0.5.0}/encommon/types/test/__init__.py +0 -0
  54. {encommon-0.4.1 → encommon-0.5.0}/encommon/types/test/test_empty.py +0 -0
  55. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/__init__.py +0 -0
  56. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/common.py +0 -0
  57. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/match.py +0 -0
  58. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/paths.py +0 -0
  59. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/stdout.py +0 -0
  60. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/test/__init__.py +0 -0
  61. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/test/test_match.py +0 -0
  62. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/test/test_paths.py +0 -0
  63. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/test/test_sample.py +0 -0
  64. {encommon-0.4.1 → encommon-0.5.0}/encommon/utils/test/test_stdout.py +0 -0
  65. {encommon-0.4.1 → encommon-0.5.0}/encommon.egg-info/dependency_links.txt +0 -0
  66. {encommon-0.4.1 → encommon-0.5.0}/encommon.egg-info/requires.txt +0 -0
  67. {encommon-0.4.1 → encommon-0.5.0}/encommon.egg-info/top_level.txt +0 -0
  68. {encommon-0.4.1 → encommon-0.5.0}/pyproject.toml +0 -0
  69. {encommon-0.4.1 → encommon-0.5.0}/reqs-install.txt +0 -0
  70. {encommon-0.4.1 → encommon-0.5.0}/setup.cfg +0 -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,13 +1,14 @@
1
1
  # Enasis Network Common Library
2
2
 
3
- [![](https://img.shields.io/github/actions/workflow/status/enasisnetwork/encommon/build.yml?style=flat-square&label=GitHub%20actions)](https://github.com/enasisnetwork/encommon/actions)
4
- [![](https://img.shields.io/readthedocs/encommon?style=flat-square&label=Read%20the%20Docs)](https://encommon.readthedocs.io/en/stable)
5
- [![](https://img.shields.io/pypi/v/encommon.svg?style=flat-square&label=PyPi%20version)](https://pypi.org/project/encommon)
6
- [![](https://img.shields.io/pypi/dm/encommon?style=flat-square&label=PyPi%20downloads)](https://pypi.org/project/encommon)
7
-
8
3
  Common classes and functions used in various public and private projects for
9
4
  [Enasis Network](https://github.com/enasisnetwork).
10
5
 
6
+ [![](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>
7
+ [![codecov](https://codecov.io/gh/enasisnetwork/encommon/graph/badge.svg?token=7PGOXKJU0E)](https://codecov.io/gh/enasisnetwork/encommon)<br>
8
+ [![](https://img.shields.io/readthedocs/encommon?style=flat-square&label=Read%20the%20Docs)](https://encommon.readthedocs.io/en/stable)<br>
9
+ [![](https://img.shields.io/pypi/v/encommon.svg?style=flat-square&label=PyPi%20version)](https://pypi.org/project/encommon)<br>
10
+ [![](https://img.shields.io/pypi/dm/encommon?style=flat-square&label=PyPi%20downloads)](https://pypi.org/project/encommon)
11
+
11
12
  ## Installing the package
12
13
  Installing stable from the PyPi repository
13
14
  ```
@@ -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)
@@ -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]
@@ -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']
@@ -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'
@@ -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
 
@@ -0,0 +1 @@
1
+ 0.5.0
@@ -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
  ```
@@ -5,6 +5,7 @@ pyproject.toml
5
5
  reqs-install.txt
6
6
  setup.cfg
7
7
  encommon/__init__.py
8
+ encommon/conftest.py
8
9
  encommon/py.typed
9
10
  encommon/version.txt
10
11
  encommon.egg-info/PKG-INFO
@@ -20,7 +21,6 @@ encommon/config/logger.py
20
21
  encommon/config/params.py
21
22
  encommon/config/paths.py
22
23
  encommon/config/test/__init__.py
23
- encommon/config/test/conftest.py
24
24
  encommon/config/test/test_common.py
25
25
  encommon/config/test/test_config.py
26
26
  encommon/config/test/test_files.py
@@ -50,9 +50,11 @@ encommon/times/test/test_window.py
50
50
  encommon/types/__init__.py
51
51
  encommon/types/dicts.py
52
52
  encommon/types/empty.py
53
+ encommon/types/strings.py
53
54
  encommon/types/test/__init__.py
54
55
  encommon/types/test/test_dicts.py
55
56
  encommon/types/test/test_empty.py
57
+ encommon/types/test/test_strings.py
56
58
  encommon/utils/__init__.py
57
59
  encommon/utils/common.py
58
60
  encommon/utils/match.py
@@ -1 +0,0 @@
1
- 0.4.1
File without changes
File without changes
File without changes
@@ -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
File without changes
File without changes
File without changes