encommon 0.11.1__tar.gz → 0.12.1__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 (81) hide show
  1. {encommon-0.11.1/encommon.egg-info → encommon-0.12.1}/PKG-INFO +32 -14
  2. {encommon-0.11.1 → encommon-0.12.1}/README.md +30 -13
  3. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/logger.py +3 -0
  4. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/params.py +0 -2
  5. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/params.py +0 -4
  6. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_timers.py +38 -32
  7. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_windows.py +47 -45
  8. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/timers.py +107 -83
  9. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/windows.py +127 -100
  10. encommon-0.12.1/encommon/version.txt +1 -0
  11. {encommon-0.11.1 → encommon-0.12.1/encommon.egg-info}/PKG-INFO +32 -14
  12. {encommon-0.11.1 → encommon-0.12.1}/encommon.egg-info/requires.txt +1 -0
  13. {encommon-0.11.1 → encommon-0.12.1}/reqs-install.txt +1 -0
  14. encommon-0.11.1/encommon/version.txt +0 -1
  15. {encommon-0.11.1 → encommon-0.12.1}/LICENSE +0 -0
  16. {encommon-0.11.1 → encommon-0.12.1}/MANIFEST.in +0 -0
  17. {encommon-0.11.1 → encommon-0.12.1}/encommon/__init__.py +0 -0
  18. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/__init__.py +0 -0
  19. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/config.py +0 -0
  20. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/files.py +0 -0
  21. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/paths.py +0 -0
  22. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/test/__init__.py +0 -0
  23. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/test/test_config.py +0 -0
  24. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/test/test_files.py +0 -0
  25. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/test/test_logger.py +0 -0
  26. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/test/test_paths.py +0 -0
  27. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/test/test_utils.py +0 -0
  28. {encommon-0.11.1 → encommon-0.12.1}/encommon/config/utils.py +0 -0
  29. {encommon-0.11.1 → encommon-0.12.1}/encommon/conftest.py +0 -0
  30. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/__init__.py +0 -0
  31. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/crypts.py +0 -0
  32. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/hashes.py +0 -0
  33. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/params.py +0 -0
  34. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/test/__init__.py +0 -0
  35. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/test/test_crypts.py +0 -0
  36. {encommon-0.11.1 → encommon-0.12.1}/encommon/crypts/test/test_hashes.py +0 -0
  37. {encommon-0.11.1 → encommon-0.12.1}/encommon/py.typed +0 -0
  38. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/__init__.py +0 -0
  39. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/common.py +0 -0
  40. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/duration.py +0 -0
  41. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/parse.py +0 -0
  42. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/__init__.py +0 -0
  43. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_duration.py +0 -0
  44. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_params.py +0 -0
  45. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_parse.py +0 -0
  46. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_timer.py +0 -0
  47. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_times.py +0 -0
  48. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_utils.py +0 -0
  49. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/test/test_window.py +0 -0
  50. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/timer.py +0 -0
  51. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/times.py +0 -0
  52. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/utils.py +0 -0
  53. {encommon-0.11.1 → encommon-0.12.1}/encommon/times/window.py +0 -0
  54. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/__init__.py +0 -0
  55. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/dicts.py +0 -0
  56. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/empty.py +0 -0
  57. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/notate.py +0 -0
  58. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/strings.py +0 -0
  59. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/test/__init__.py +0 -0
  60. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/test/test_dicts.py +0 -0
  61. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/test/test_empty.py +0 -0
  62. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/test/test_notate.py +0 -0
  63. {encommon-0.11.1 → encommon-0.12.1}/encommon/types/test/test_strings.py +0 -0
  64. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/__init__.py +0 -0
  65. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/common.py +0 -0
  66. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/files.py +0 -0
  67. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/match.py +0 -0
  68. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/paths.py +0 -0
  69. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/sample.py +0 -0
  70. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/stdout.py +0 -0
  71. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/test/__init__.py +0 -0
  72. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/test/test_files.py +0 -0
  73. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/test/test_match.py +0 -0
  74. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/test/test_paths.py +0 -0
  75. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/test/test_sample.py +0 -0
  76. {encommon-0.11.1 → encommon-0.12.1}/encommon/utils/test/test_stdout.py +0 -0
  77. {encommon-0.11.1 → encommon-0.12.1}/encommon.egg-info/SOURCES.txt +0 -0
  78. {encommon-0.11.1 → encommon-0.12.1}/encommon.egg-info/dependency_links.txt +0 -0
  79. {encommon-0.11.1 → encommon-0.12.1}/encommon.egg-info/top_level.txt +0 -0
  80. {encommon-0.11.1 → encommon-0.12.1}/pyproject.toml +0 -0
  81. {encommon-0.11.1 → encommon-0.12.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: encommon
3
- Version: 0.11.1
3
+ Version: 0.12.1
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Classifier: Programming Language :: Python :: 3
@@ -15,6 +15,7 @@ Requires-Dist: pydantic
15
15
  Requires-Dist: python-dateutil
16
16
  Requires-Dist: pyyaml
17
17
  Requires-Dist: snaptime
18
+ Requires-Dist: sqlalchemy
18
19
 
19
20
  # Enasis Network Common Library
20
21
 
@@ -73,16 +74,33 @@ information found in the `htmlcov` folder in the root of the project.
73
74
  make -s pytest
74
75
  ```
75
76
 
76
- ## Build and upload to PyPi
77
- Build the package.
78
- ```
79
- make -s pypackage
80
- ```
81
- Upload to the test PyPi.
82
- ```
83
- make -s pypi-upload-test
84
- ```
85
- Upload to the prod PyPi.
86
- ```
87
- make -s pypi-upload-prod
88
- ```
77
+ ## Version management
78
+ :warning: Ensure that no changes are pending.
79
+
80
+ 1. Rebuild the environment.
81
+ ```
82
+ make -s check-revenv
83
+ ```
84
+
85
+ 1. Update the [version.txt](encommon/version.txt) file.
86
+
87
+ 1. Push to the `main` branch.
88
+
89
+ 1. Create [repository](https://github.com/enasisnetwork/encommon) release.
90
+
91
+ 1. Build the Python package.<br>
92
+ ```
93
+ make -s pypackage
94
+ ```
95
+
96
+ 1. Upload Python package to PyPi test.
97
+ ```
98
+ make -s pypi-upload-test
99
+ ```
100
+
101
+ 1. Upload Python package to PyPi prod.
102
+ ```
103
+ make -s pypi-upload-prod
104
+ ```
105
+
106
+ 1. Update [Read the Docs](https://encommon.readthedocs.io) documentation.
@@ -55,16 +55,33 @@ information found in the `htmlcov` folder in the root of the project.
55
55
  make -s pytest
56
56
  ```
57
57
 
58
- ## Build and upload to PyPi
59
- Build the package.
60
- ```
61
- make -s pypackage
62
- ```
63
- Upload to the test PyPi.
64
- ```
65
- make -s pypi-upload-test
66
- ```
67
- Upload to the prod PyPi.
68
- ```
69
- make -s pypi-upload-prod
70
- ```
58
+ ## Version management
59
+ :warning: Ensure that no changes are pending.
60
+
61
+ 1. Rebuild the environment.
62
+ ```
63
+ make -s check-revenv
64
+ ```
65
+
66
+ 1. Update the [version.txt](encommon/version.txt) file.
67
+
68
+ 1. Push to the `main` branch.
69
+
70
+ 1. Create [repository](https://github.com/enasisnetwork/encommon) release.
71
+
72
+ 1. Build the Python package.<br>
73
+ ```
74
+ make -s pypackage
75
+ ```
76
+
77
+ 1. Upload Python package to PyPi test.
78
+ ```
79
+ make -s pypi-upload-test
80
+ ```
81
+
82
+ 1. Upload Python package to PyPi prod.
83
+ ```
84
+ make -s pypi-upload-prod
85
+ ```
86
+
87
+ 1. Update [Read the Docs](https://encommon.readthedocs.io) documentation.
@@ -266,6 +266,9 @@ class Message:
266
266
  class FileFormatter(Formatter):
267
267
  """
268
268
  Supplement class for built-in logger exception formatter.
269
+
270
+ .. note::
271
+ Input parameters are not defined, check parent class.
269
272
  """
270
273
 
271
274
 
@@ -37,8 +37,6 @@ class LoggerParams(BaseModel, extra='forbid'):
37
37
  :param stdo_level: Minimum level for the message to pass.
38
38
  :param file_level: Minimum level for the message to pass.
39
39
  :param file_path: Enables writing to the filesystem path.
40
- :param data: Keyword arguments passed to Pydantic model.
41
- Parameter is picked up by autodoc, please ignore.
42
40
  """
43
41
 
44
42
  stdo_level: Optional[LOGLEVELS] = None
@@ -24,8 +24,6 @@ class TimerParams(BaseModel, extra='forbid'):
24
24
 
25
25
  :param timer: Seconds that are used for related timer.
26
26
  :param start: Optional time for when the timer started.
27
- :param data: Keyword arguments passed to Pydantic model.
28
- Parameter is picked up by autodoc, please ignore.
29
27
  """
30
28
 
31
29
  timer: float
@@ -81,8 +79,6 @@ class WindowParams(BaseModel, extra='forbid'):
81
79
  :param stop: Determine the ending for scheduling window.
82
80
  :param anchor: Optionally define time anchor for window.
83
81
  :param delay: Period of time schedulng will be delayed.
84
- :param data: Keyword arguments passed to Pydantic model.
85
- Parameter is picked up by autodoc, please ignore.
86
82
  """
87
83
 
88
84
  window: SCHEDULE
@@ -17,6 +17,7 @@ from pytest import raises
17
17
  from ..params import TimerParams
18
18
  from ..params import TimersParams
19
19
  from ..timers import Timers
20
+ from ..timers import TimersTable
20
21
  from ..times import Times
21
22
  from ...types import inrepr
22
23
  from ...types import instr
@@ -34,40 +35,45 @@ def timers(
34
35
  :returns: Newly constructed instance of related class.
35
36
  """
36
37
 
38
+
37
39
  source: dict[str, Any] = {
38
40
  'one': {'timer': 1},
39
41
  'two': {'timer': 1}}
40
42
 
43
+
41
44
  params = TimersParams(
42
45
  timers=source)
43
46
 
47
+ store = (
48
+ f'sqlite:///{tmp_path}'
49
+ '/cache.db')
50
+
44
51
  timers = Timers(
45
52
  params,
46
- file=f'{tmp_path}/cache.db')
47
-
48
- sqlite = timers.sqlite
49
-
50
- sqlite.execute(
51
- """
52
- insert into timers
53
- ("group", "unique",
54
- "update")
55
- values (
56
- "default", "two",
57
- "1970-01-01T00:00:00Z")
58
- """) # noqa: LIT003
59
-
60
- sqlite.execute(
61
- """
62
- insert into timers
63
- ("group", "unique",
64
- "update")
65
- values (
66
- "default", "tre",
67
- "1970-01-01T00:00:00Z")
68
- """) # noqa: LIT003
69
-
70
- sqlite.commit()
53
+ store=store)
54
+
55
+ session = timers.store_session
56
+
57
+
58
+ timer = TimersTable(
59
+ group='default',
60
+ unique='two',
61
+ update='1970-01-01T00:00:00Z')
62
+
63
+ session.add(timer)
64
+
65
+ session.commit()
66
+
67
+
68
+ timer = TimersTable(
69
+ group='default',
70
+ unique='tre',
71
+ update='1970-01-01T00:00:00Z')
72
+
73
+ session.add(timer)
74
+
75
+ session.commit()
76
+
71
77
 
72
78
  timers.load_children()
73
79
 
@@ -89,10 +95,10 @@ def test_Timers(
89
95
 
90
96
  assert attrs == [
91
97
  '_Timers__params',
92
- '_Timers__sqlite',
93
- '_Timers__file',
94
- '_Timers__table',
98
+ '_Timers__store',
95
99
  '_Timers__group',
100
+ '_Timers__store_engine',
101
+ '_Timers__store_session',
96
102
  '_Timers__timers']
97
103
 
98
104
 
@@ -109,13 +115,13 @@ def test_Timers(
109
115
 
110
116
  assert timers.params is not None
111
117
 
112
- assert timers.sqlite is not None
118
+ assert timers.store[:6] == 'sqlite'
113
119
 
114
- assert timers.file[-8:] == 'cache.db'
120
+ assert timers.group == 'default'
115
121
 
116
- assert timers.table == 'timers'
122
+ assert timers.store_engine is not None
117
123
 
118
- assert timers.group == 'default'
124
+ assert timers.store_session is not None
119
125
 
120
126
  assert len(timers.children) == 2
121
127
 
@@ -17,6 +17,7 @@ from pytest import raises
17
17
  from ..params import WindowParams
18
18
  from ..params import WindowsParams
19
19
  from ..windows import Windows
20
+ from ..windows import WindowsTable
20
21
  from ...types import inrepr
21
22
  from ...types import instr
22
23
 
@@ -33,6 +34,7 @@ def windows(
33
34
  :returns: Newly constructed instance of related class.
34
35
  """
35
36
 
37
+
36
38
  source: dict[str, Any] = {
37
39
  'one': WindowParams(
38
40
  window='* * * * *',
@@ -45,46 +47,46 @@ def windows(
45
47
  stop=620,
46
48
  delay=10)}
47
49
 
50
+
48
51
  params = WindowsParams(
49
52
  windows=source)
50
53
 
54
+ store = (
55
+ f'sqlite:///{tmp_path}'
56
+ '/cache.db')
57
+
51
58
  windows = Windows(
52
59
  params,
53
60
  start=310,
54
61
  stop=610,
55
- file=f'{tmp_path}/cache.db')
56
-
57
- sqlite = windows.sqlite
58
-
59
- sqlite.execute(
60
- """
61
- insert into windows
62
- ("group", "unique",
63
- "last", "next",
64
- "update")
65
- values (
66
- "default", "two",
67
- "1970-01-01T00:06:00Z",
68
- "1970-01-01T00:07:00Z",
69
- "1970-01-01T01:00:00Z")
70
- """) # noqa: LIT003
71
-
72
- sqlite.commit()
73
-
74
- sqlite.execute(
75
- """
76
- insert into windows
77
- ("group", "unique",
78
- "last", "next",
79
- "update")
80
- values (
81
- "default", "tre",
82
- "1970-01-01T00:06:00Z",
83
- "1970-01-01T00:07:00Z",
84
- "1970-01-01T01:00:00Z")
85
- """) # noqa: LIT003
86
-
87
- sqlite.commit()
62
+ store=store)
63
+
64
+ session = windows.store_session
65
+
66
+
67
+ window = WindowsTable(
68
+ group='default',
69
+ unique='two',
70
+ last='1970-01-01T00:06:00Z',
71
+ next='1970-01-01T00:07:00Z',
72
+ update='1970-01-01T01:00:00Z')
73
+
74
+ session.add(window)
75
+
76
+ session.commit()
77
+
78
+
79
+ window = WindowsTable(
80
+ group='default',
81
+ unique='tre',
82
+ last='1970-01-01T00:06:00Z',
83
+ next='1970-01-01T00:07:00Z',
84
+ update='1970-01-01T01:00:00Z')
85
+
86
+ session.add(window)
87
+
88
+ session.commit()
89
+
88
90
 
89
91
  windows.load_children()
90
92
 
@@ -106,12 +108,12 @@ def test_Windows(
106
108
 
107
109
  assert attrs == [
108
110
  '_Windows__params',
111
+ '_Windows__store',
112
+ '_Windows__group',
113
+ '_Windows__store_engine',
114
+ '_Windows__store_session',
109
115
  '_Windows__start',
110
116
  '_Windows__stop',
111
- '_Windows__sqlite',
112
- '_Windows__file',
113
- '_Windows__table',
114
- '_Windows__group',
115
117
  '_Windows__windows']
116
118
 
117
119
 
@@ -128,19 +130,19 @@ def test_Windows(
128
130
 
129
131
  assert windows.params is not None
130
132
 
131
- assert windows.start == (
132
- '1970-01-01T00:05:10Z')
133
+ assert windows.store[:6] == 'sqlite'
133
134
 
134
- assert windows.stop == (
135
- '1970-01-01T00:10:10Z')
135
+ assert windows.group == 'default'
136
136
 
137
- assert windows.sqlite is not None
137
+ assert windows.store_engine is not None
138
138
 
139
- assert windows.file[-8:] == 'cache.db'
139
+ assert windows.store_session is not None
140
140
 
141
- assert windows.table == 'windows'
141
+ assert windows.start == (
142
+ '1970-01-01T00:05:10Z')
142
143
 
143
- assert windows.group == 'default'
144
+ assert windows.stop == (
145
+ '1970-01-01T00:10:10Z')
144
146
 
145
147
  assert len(windows.children) == 2
146
148