lockss-pybasic 0.3.0.dev6__py3-none-any.whl → 0.3.0.dev8__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.
- lockss/pybasic/__init__.py +1 -1
- lockss/pybasic/nodeutil.py +24 -15
- {lockss_pybasic-0.3.0.dev6.dist-info → lockss_pybasic-0.3.0.dev8.dist-info}/METADATA +2 -2
- lockss_pybasic-0.3.0.dev8.dist-info/RECORD +10 -0
- lockss_pybasic-0.3.0.dev6.dist-info/RECORD +0 -10
- {lockss_pybasic-0.3.0.dev6.dist-info → lockss_pybasic-0.3.0.dev8.dist-info}/WHEEL +0 -0
- {lockss_pybasic-0.3.0.dev6.dist-info → lockss_pybasic-0.3.0.dev8.dist-info}/licenses/LICENSE +0 -0
lockss/pybasic/__init__.py
CHANGED
lockss/pybasic/nodeutil.py
CHANGED
|
@@ -35,14 +35,14 @@ LOCKSS node utilities.
|
|
|
35
35
|
from enum import Enum
|
|
36
36
|
from re import Match, Pattern
|
|
37
37
|
import re
|
|
38
|
-
from typing import Annotated, Any, ClassVar, Literal, Optional, Union
|
|
38
|
+
from typing import Annotated, Any, ClassVar, Literal, Optional, TypeAlias, Union
|
|
39
39
|
|
|
40
40
|
from annotated_types import Ge, Le
|
|
41
41
|
from pydantic import BaseModel, BeforeValidator, Field, TypeAdapter
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
#: An annotated type for port numbers (0-65535)
|
|
45
|
-
PortNumber = Annotated[int, Ge(0), Le(65535)]
|
|
45
|
+
PortNumber: TypeAlias = Annotated[int, Ge(0), Le(65535)]
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
class NodeTypeEnum(Enum):
|
|
@@ -61,6 +61,12 @@ class NodeProtocolEnum(Enum):
|
|
|
61
61
|
HTTPS = 'https'
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
NodeSpecKind: TypeAlias = Literal['NodeSpec']
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
NodeIdentifier: TypeAlias = str
|
|
68
|
+
|
|
69
|
+
|
|
64
70
|
class BaseNodeSpec(BaseModel):
|
|
65
71
|
|
|
66
72
|
DEFAULT_PROTOCOL: ClassVar[NodeProtocolEnum] = NodeProtocolEnum.HTTP
|
|
@@ -68,6 +74,12 @@ class BaseNodeSpec(BaseModel):
|
|
|
68
74
|
TYPE_FIELD: ClassVar[dict[str, str]] = dict(title='Type',
|
|
69
75
|
description="The node's type")
|
|
70
76
|
|
|
77
|
+
kind: NodeSpecKind = Field(title='Kind',
|
|
78
|
+
description="This object's kind")
|
|
79
|
+
|
|
80
|
+
id: NodeIdentifier = Field(title='Node Identifier',
|
|
81
|
+
description='An identifier for the node')
|
|
82
|
+
|
|
71
83
|
protocol: NodeProtocolEnum = Field(default=DEFAULT_PROTOCOL,
|
|
72
84
|
title='Protocol',
|
|
73
85
|
description="The protocol for reaching the node")
|
|
@@ -132,14 +144,14 @@ _RE_COMPACT_NODE_SPEC: Pattern[str] = re.compile(r'((?P<protocol>https?)://)?(?P
|
|
|
132
144
|
|
|
133
145
|
|
|
134
146
|
#: A type for LOCKSS node specification strings.
|
|
135
|
-
CompactNodeSpec = str
|
|
147
|
+
CompactNodeSpec: TypeAlias = str
|
|
136
148
|
|
|
137
149
|
|
|
138
150
|
def _parse_compact_node_spec(compact_node_spec: CompactNodeSpec) -> dict[str, str]:
|
|
139
151
|
mat: Optional[Match[str]] = _RE_COMPACT_NODE_SPEC.fullmatch(compact_node_spec)
|
|
140
152
|
if mat is None:
|
|
141
153
|
raise ValueError(f'Invalid compact node specification: {compact_node_spec}')
|
|
142
|
-
d = dict(host=mat.group('host'))
|
|
154
|
+
d = dict(kind='NodeSpec', id=compact_node_spec, host=mat.group('host'))
|
|
143
155
|
if prot := mat.group('protocol'):
|
|
144
156
|
d['protocol'] = prot
|
|
145
157
|
five = ('configuration', 'poller', 'crawler', 'metadata', 'soap')
|
|
@@ -147,7 +159,7 @@ def _parse_compact_node_spec(compact_node_spec: CompactNodeSpec) -> dict[str, st
|
|
|
147
159
|
if any(mat.group(x) for x in five) or len(repo_or_ui) >= 5:
|
|
148
160
|
# 10000 or larger: assume V2
|
|
149
161
|
d['type'] = NodeTypeEnum.V2.value
|
|
150
|
-
d['repository'] = repo_or_ui
|
|
162
|
+
d['repository'] = repo_or_ui # all these strings will be coerced to int
|
|
151
163
|
elif len(repo_or_ui) == 4:
|
|
152
164
|
# 1000 through 9999: assume V1
|
|
153
165
|
d['type'] = NodeTypeEnum.V1.value
|
|
@@ -159,7 +171,7 @@ def _parse_compact_node_spec(compact_node_spec: CompactNodeSpec) -> dict[str, st
|
|
|
159
171
|
d['type'] = NodeTypeEnum.V2.value
|
|
160
172
|
for k in five:
|
|
161
173
|
if p := mat.group(k):
|
|
162
|
-
d[k] = p
|
|
174
|
+
d[k] = p
|
|
163
175
|
return d
|
|
164
176
|
|
|
165
177
|
|
|
@@ -171,7 +183,7 @@ def _maybe_deserialize_compact_node_spec(value: Any) -> Any:
|
|
|
171
183
|
|
|
172
184
|
#: A type for LOCKSS node specifications, that also accepts a compact LOCKSS
|
|
173
185
|
#: node specification.
|
|
174
|
-
NodeSpec = Annotated[
|
|
186
|
+
NodeSpec: TypeAlias = Annotated[
|
|
175
187
|
Annotated[Union[NodeSpec1, NodeSpec2], Field(discriminator='type')],
|
|
176
188
|
BeforeValidator(_maybe_deserialize_compact_node_spec)
|
|
177
189
|
]
|
|
@@ -191,13 +203,10 @@ def get_node_spec_adapter() -> TypeAdapter[NodeSpec]:
|
|
|
191
203
|
return _node_spec_adapter
|
|
192
204
|
|
|
193
205
|
|
|
194
|
-
NodeSetKind = Literal['NodeSet']
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
NodeSetIdentifier = str
|
|
206
|
+
NodeSetKind: TypeAlias = Literal['NodeSet']
|
|
198
207
|
|
|
199
208
|
|
|
200
|
-
|
|
209
|
+
NodeSetIdentifier: TypeAlias = str
|
|
201
210
|
|
|
202
211
|
|
|
203
212
|
class NodeSet(BaseModel):
|
|
@@ -211,6 +220,6 @@ class NodeSet(BaseModel):
|
|
|
211
220
|
name: str = Field(title='Node Set Name',
|
|
212
221
|
description='A name for the node set')
|
|
213
222
|
|
|
214
|
-
nodes:
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
nodes: list[NodeSpec] = Field(min_length=1,
|
|
224
|
+
title='Nodes',
|
|
225
|
+
description='A non-empty list of nodes')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lockss-pybasic
|
|
3
|
-
Version: 0.3.0.
|
|
3
|
+
Version: 0.3.0.dev8
|
|
4
4
|
Summary: Basic Python utilities
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
License-File: LICENSE
|
|
@@ -26,7 +26,7 @@ Description-Content-Type: text/x-rst
|
|
|
26
26
|
lockss-pybasic
|
|
27
27
|
==============
|
|
28
28
|
|
|
29
|
-
.. |RELEASE| replace:: 0.3.0-
|
|
29
|
+
.. |RELEASE| replace:: 0.3.0-dev8
|
|
30
30
|
.. |RELEASE_DATE| replace:: NOT YET RELEASED
|
|
31
31
|
|
|
32
32
|
**Latest release:** |RELEASE| (|RELEASE_DATE|)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
lockss/pybasic/__init__.py,sha256=CV8emykQGTRFAQwd46pu6DRw5VCBKOejBFwt-LCzud8,1678
|
|
2
|
+
lockss/pybasic/auidutil.py,sha256=Q4vjjGfymiXVwPu35RyyLZBnViv8mDJKCjOyJb-sbS8,13921
|
|
3
|
+
lockss/pybasic/cliutil.py,sha256=-o5YIh5JPDxwyZ61U9iZshsmzYwOHW-HHFa2ndFO__g,8130
|
|
4
|
+
lockss/pybasic/errorutil.py,sha256=4EaO0a1yIG1DbWltASeT15bg1bGg5kOYspsW0iJdVLc,1951
|
|
5
|
+
lockss/pybasic/fileutil.py,sha256=P_XW_UX6hVvP45vRV8fduclbGmoFflW83a6ZfFE-8Hc,2966
|
|
6
|
+
lockss/pybasic/nodeutil.py,sha256=-MSCS79JMAgoja00lTs0ycHUbI5JJHvCCQMRXOyB-fc,8293
|
|
7
|
+
lockss_pybasic-0.3.0.dev8.dist-info/METADATA,sha256=TtVbPwglY4nlCX055bXsCcjObdvn4XcT8mbGccM_i0o,2494
|
|
8
|
+
lockss_pybasic-0.3.0.dev8.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
9
|
+
lockss_pybasic-0.3.0.dev8.dist-info/licenses/LICENSE,sha256=EOxPunNz3XP6AjgbPFolu-d9BS_AF9TtKn1WXgeYPsE,1506
|
|
10
|
+
lockss_pybasic-0.3.0.dev8.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
lockss/pybasic/__init__.py,sha256=CadXEjtP9aw_ojXq1X15LcxIM8jsPDp71g-wailK6vM,1678
|
|
2
|
-
lockss/pybasic/auidutil.py,sha256=Q4vjjGfymiXVwPu35RyyLZBnViv8mDJKCjOyJb-sbS8,13921
|
|
3
|
-
lockss/pybasic/cliutil.py,sha256=-o5YIh5JPDxwyZ61U9iZshsmzYwOHW-HHFa2ndFO__g,8130
|
|
4
|
-
lockss/pybasic/errorutil.py,sha256=4EaO0a1yIG1DbWltASeT15bg1bGg5kOYspsW0iJdVLc,1951
|
|
5
|
-
lockss/pybasic/fileutil.py,sha256=P_XW_UX6hVvP45vRV8fduclbGmoFflW83a6ZfFE-8Hc,2966
|
|
6
|
-
lockss/pybasic/nodeutil.py,sha256=DquB0bVdgfZHCTfu2xMZpEQ-oVzBc9ArHRiAKBOozmI,7931
|
|
7
|
-
lockss_pybasic-0.3.0.dev6.dist-info/METADATA,sha256=UjX2kivXGti545A930Ce9BDVZILZjkCRtN4Dsf-53aw,2494
|
|
8
|
-
lockss_pybasic-0.3.0.dev6.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
9
|
-
lockss_pybasic-0.3.0.dev6.dist-info/licenses/LICENSE,sha256=EOxPunNz3XP6AjgbPFolu-d9BS_AF9TtKn1WXgeYPsE,1506
|
|
10
|
-
lockss_pybasic-0.3.0.dev6.dist-info/RECORD,,
|
|
File without changes
|
{lockss_pybasic-0.3.0.dev6.dist-info → lockss_pybasic-0.3.0.dev8.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|