encommon 0.22.9__py3-none-any.whl → 0.22.11__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/times/parse.py +9 -3
- encommon/times/test/test_timers.py +25 -18
- encommon/times/test/test_windows.py +29 -21
- encommon/times/timers.py +236 -125
- encommon/times/windows.py +275 -149
- encommon/types/__init__.py +2 -0
- encommon/types/notate.py +3 -2
- encommon/types/types.py +1 -0
- encommon/version.txt +1 -1
- {encommon-0.22.9.dist-info → encommon-0.22.11.dist-info}/METADATA +1 -1
- {encommon-0.22.9.dist-info → encommon-0.22.11.dist-info}/RECORD +14 -14
- {encommon-0.22.9.dist-info → encommon-0.22.11.dist-info}/WHEEL +1 -1
- {encommon-0.22.9.dist-info → encommon-0.22.11.dist-info}/licenses/LICENSE +0 -0
- {encommon-0.22.9.dist-info → encommon-0.22.11.dist-info}/top_level.txt +0 -0
encommon/times/parse.py
CHANGED
@@ -8,6 +8,7 @@ is permitted, for more information consult the project license file.
|
|
8
8
|
|
9
9
|
|
10
10
|
from contextlib import suppress
|
11
|
+
from copy import deepcopy
|
11
12
|
from datetime import datetime
|
12
13
|
from re import match as re_match
|
13
14
|
from typing import Optional
|
@@ -82,7 +83,9 @@ def parse_time(
|
|
82
83
|
if (source is not None
|
83
84
|
and hasattr(source, 'source')):
|
84
85
|
|
85
|
-
source =
|
86
|
+
source = deepcopy(
|
87
|
+
source.source)
|
88
|
+
|
86
89
|
assert isinstance(
|
87
90
|
source, datetime)
|
88
91
|
|
@@ -106,10 +109,12 @@ def parse_time(
|
|
106
109
|
.astimezone(tzinfo))
|
107
110
|
|
108
111
|
if source in ['max', float('inf')]:
|
109
|
-
source =
|
112
|
+
source = deepcopy(
|
113
|
+
datetime.max)
|
110
114
|
|
111
115
|
if source in ['min', float('-inf')]:
|
112
|
-
source =
|
116
|
+
source = deepcopy(
|
117
|
+
datetime.min)
|
113
118
|
|
114
119
|
if (isinstance(source, str)
|
115
120
|
and re_match(SNAPABLE, source)):
|
@@ -127,6 +132,7 @@ def parse_time(
|
|
127
132
|
|
128
133
|
if (isinstance(source, datetime)
|
129
134
|
and not source.tzinfo):
|
135
|
+
source = deepcopy(source)
|
130
136
|
source = source.replace(
|
131
137
|
tzinfo=findtz(tzname))
|
132
138
|
|
@@ -14,10 +14,8 @@ from pytest import fixture
|
|
14
14
|
from pytest import raises
|
15
15
|
|
16
16
|
from ..params import TimerParams
|
17
|
-
from ..params import TimersParams
|
18
17
|
from ..time import Time
|
19
18
|
from ..timers import Timers
|
20
|
-
from ..timers import TimersTable
|
21
19
|
from ...types import DictStrAny
|
22
20
|
from ...types import inrepr
|
23
21
|
from ...types import instr
|
@@ -36,49 +34,54 @@ def timers(
|
|
36
34
|
:returns: Newly constructed instance of related class.
|
37
35
|
"""
|
38
36
|
|
37
|
+
model = TimerParams
|
39
38
|
|
40
39
|
source: DictStrAny = {
|
41
|
-
'one':
|
42
|
-
'two':
|
40
|
+
'one': model(timer=1),
|
41
|
+
'two': model(timer=1)}
|
43
42
|
|
44
43
|
|
45
|
-
params = TimersParams(
|
46
|
-
timers=source)
|
47
|
-
|
48
44
|
store = (
|
49
45
|
f'sqlite:///{tmp_path}'
|
50
46
|
'/cache.db')
|
51
47
|
|
52
48
|
timers = Timers(
|
53
|
-
params,
|
54
49
|
store=store)
|
55
50
|
|
56
|
-
|
51
|
+
table = (
|
52
|
+
timers
|
53
|
+
.store_table)
|
54
|
+
|
55
|
+
session = (
|
56
|
+
timers
|
57
|
+
.store_session)
|
57
58
|
|
58
59
|
|
59
|
-
|
60
|
+
record = table(
|
60
61
|
group='default',
|
61
62
|
unique='two',
|
62
63
|
last='1970-01-01T00:00:00Z',
|
63
64
|
update='1970-01-01T00:00:00Z')
|
64
65
|
|
65
|
-
session.
|
66
|
-
|
67
|
-
session.commit()
|
68
|
-
|
66
|
+
session.merge(record)
|
69
67
|
|
70
|
-
|
68
|
+
record = table(
|
71
69
|
group='default',
|
72
70
|
unique='tre',
|
73
71
|
last='1970-01-01T00:00:00Z',
|
74
72
|
update='1970-01-01T00:00:00Z')
|
75
73
|
|
76
|
-
session.
|
74
|
+
session.merge(record)
|
77
75
|
|
78
76
|
session.commit()
|
79
77
|
|
80
78
|
|
81
|
-
timers.
|
79
|
+
timers.create(
|
80
|
+
'one', source['one'])
|
81
|
+
|
82
|
+
timers.create(
|
83
|
+
'two', source['two'])
|
84
|
+
|
82
85
|
|
83
86
|
return timers
|
84
87
|
|
@@ -100,9 +103,11 @@ def test_Timers(
|
|
100
103
|
'_Timers__params',
|
101
104
|
'_Timers__store',
|
102
105
|
'_Timers__group',
|
106
|
+
'_Timers__table',
|
107
|
+
'_Timers__locker',
|
103
108
|
'_Timers__sengine',
|
104
109
|
'_Timers__session',
|
105
|
-
'
|
110
|
+
'_Timers__childs']
|
106
111
|
|
107
112
|
|
108
113
|
assert inrepr(
|
@@ -123,6 +128,8 @@ def test_Timers(
|
|
123
128
|
|
124
129
|
assert timers.group == 'default'
|
125
130
|
|
131
|
+
assert timers.store_table
|
132
|
+
|
126
133
|
assert timers.store_engine
|
127
134
|
|
128
135
|
assert timers.store_session
|
@@ -14,9 +14,7 @@ from pytest import fixture
|
|
14
14
|
from pytest import raises
|
15
15
|
|
16
16
|
from ..params import WindowParams
|
17
|
-
from ..params import WindowsParams
|
18
17
|
from ..windows import Windows
|
19
|
-
from ..windows import WindowsTable
|
20
18
|
from ...types import DictStrAny
|
21
19
|
from ...types import inrepr
|
22
20
|
from ...types import instr
|
@@ -35,61 +33,66 @@ def windows(
|
|
35
33
|
:returns: Newly constructed instance of related class.
|
36
34
|
"""
|
37
35
|
|
36
|
+
model = WindowParams
|
38
37
|
|
39
38
|
source: DictStrAny = {
|
40
|
-
'one':
|
39
|
+
'one': model(
|
41
40
|
window='* * * * *',
|
42
|
-
start=
|
41
|
+
start=300,
|
43
42
|
stop=610,
|
44
43
|
delay=10),
|
45
|
-
'two':
|
44
|
+
'two': model(
|
46
45
|
window='* * * * *',
|
47
46
|
start=300,
|
48
47
|
stop=620,
|
49
48
|
delay=10)}
|
50
49
|
|
51
50
|
|
52
|
-
params = WindowsParams(
|
53
|
-
windows=source)
|
54
|
-
|
55
51
|
store = (
|
56
52
|
f'sqlite:///{tmp_path}'
|
57
53
|
'/cache.db')
|
58
54
|
|
59
55
|
windows = Windows(
|
60
|
-
params,
|
61
56
|
start=310,
|
62
57
|
stop=610,
|
63
58
|
store=store)
|
64
59
|
|
65
|
-
|
60
|
+
table = (
|
61
|
+
windows
|
62
|
+
.store_table)
|
66
63
|
|
64
|
+
session = (
|
65
|
+
windows
|
66
|
+
.store_session)
|
67
67
|
|
68
|
-
|
68
|
+
|
69
|
+
record = table(
|
69
70
|
group='default',
|
70
71
|
unique='two',
|
71
72
|
last='1970-01-01T00:06:00Z',
|
72
73
|
next='1970-01-01T00:07:00Z',
|
73
74
|
update='1970-01-01T01:00:00Z')
|
74
75
|
|
75
|
-
session.
|
76
|
+
session.merge(record)
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
window = WindowsTable(
|
78
|
+
record = table(
|
81
79
|
group='default',
|
82
80
|
unique='tre',
|
83
81
|
last='1970-01-01T00:06:00Z',
|
84
82
|
next='1970-01-01T00:07:00Z',
|
85
83
|
update='1970-01-01T01:00:00Z')
|
86
84
|
|
87
|
-
session.
|
85
|
+
session.merge(record)
|
88
86
|
|
89
87
|
session.commit()
|
90
88
|
|
91
89
|
|
92
|
-
windows.
|
90
|
+
windows.create(
|
91
|
+
'one', source['one'])
|
92
|
+
|
93
|
+
windows.create(
|
94
|
+
'two', source['two'])
|
95
|
+
|
93
96
|
|
94
97
|
return windows
|
95
98
|
|
@@ -111,11 +114,13 @@ def test_Windows(
|
|
111
114
|
'_Windows__params',
|
112
115
|
'_Windows__store',
|
113
116
|
'_Windows__group',
|
117
|
+
'_Windows__table',
|
118
|
+
'_Windows__locker',
|
114
119
|
'_Windows__sengine',
|
115
120
|
'_Windows__session',
|
116
121
|
'_Windows__start',
|
117
122
|
'_Windows__stop',
|
118
|
-
'
|
123
|
+
'_Windows__childs']
|
119
124
|
|
120
125
|
|
121
126
|
assert inrepr(
|
@@ -136,6 +141,8 @@ def test_Windows(
|
|
136
141
|
|
137
142
|
assert windows.group == 'default'
|
138
143
|
|
144
|
+
assert windows.store_table
|
145
|
+
|
139
146
|
assert windows.store_engine
|
140
147
|
|
141
148
|
assert windows.store_session
|
@@ -161,10 +168,10 @@ def test_Windows(
|
|
161
168
|
window = windows.children['two']
|
162
169
|
|
163
170
|
assert window.next == (
|
164
|
-
'1970-01-01T00:
|
171
|
+
'1970-01-01T00:07:00Z')
|
165
172
|
|
166
173
|
assert window.last == (
|
167
|
-
'1970-01-01T00:
|
174
|
+
'1970-01-01T00:06:00Z')
|
168
175
|
|
169
176
|
|
170
177
|
|
@@ -178,6 +185,7 @@ def test_Windows_cover(
|
|
178
185
|
"""
|
179
186
|
|
180
187
|
|
188
|
+
assert windows.ready('two')
|
181
189
|
assert windows.ready('two')
|
182
190
|
assert windows.ready('two')
|
183
191
|
assert windows.pause('two')
|