lockss-pybasic 0.3.0.dev5__tar.gz → 0.3.0.dev6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lockss-pybasic
3
- Version: 0.3.0.dev5
3
+ Version: 0.3.0.dev6
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-dev5
29
+ .. |RELEASE| replace:: 0.3.0-dev6
30
30
  .. |RELEASE_DATE| replace:: NOT YET RELEASED
31
31
 
32
32
  **Latest release:** |RELEASE| (|RELEASE_DATE|)
@@ -68,3 +68,9 @@ Release Notes
68
68
 
69
69
  See `<CHANGELOG.rst>`_.
70
70
 
71
+ ----------
72
+ Unit Tests
73
+ ----------
74
+
75
+ Run ``python -m unittest discover tests`` at the root of the project tree (where there is a directory called ``tests``).
76
+
@@ -2,7 +2,7 @@
2
2
  lockss-pybasic
3
3
  ==============
4
4
 
5
- .. |RELEASE| replace:: 0.3.0-dev5
5
+ .. |RELEASE| replace:: 0.3.0-dev6
6
6
  .. |RELEASE_DATE| replace:: NOT YET RELEASED
7
7
 
8
8
  **Latest release:** |RELEASE| (|RELEASE_DATE|)
@@ -43,3 +43,9 @@ Release Notes
43
43
  -------------
44
44
 
45
45
  See `<CHANGELOG.rst>`_.
46
+
47
+ ----------
48
+ Unit Tests
49
+ ----------
50
+
51
+ Run ``python -m unittest discover tests`` at the root of the project tree (where there is a directory called ``tests``).
@@ -28,7 +28,7 @@
28
28
 
29
29
  [project]
30
30
  name = "lockss-pybasic"
31
- version = "0.3.0-dev5" # Always change in __init__.py, and at release time in README.rst and CHANGELOG.rst
31
+ version = "0.3.0-dev6" # Always change in __init__.py, and at release time in README.rst and CHANGELOG.rst
32
32
  description = "Basic Python utilities"
33
33
  license = { text = "BSD-3-Clause" }
34
34
  readme = "README.rst"
@@ -36,4 +36,4 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
36
  POSSIBILITY OF SUCH DAMAGE.
37
37
  '''.strip()
38
38
 
39
- __version__ = '0.3.0-dev5'
39
+ __version__ = '0.3.0-dev6'
@@ -128,17 +128,17 @@ class NodeSpec2(BaseNodeSpec):
128
128
  description="The node's SOAP Compatibility Service REST API Port")
129
129
 
130
130
 
131
- _RE_NODE_REFERENCE: Pattern[str] = re.compile(r'((?P<protocol>https?)://)?(?P<host>[^:]+)(:(?P<repository>\d+|(?=:))(:(?P<configuration>\d+|(?=:))(:(?P<poller>\d+|(?=:))(:(?P<crawler>\d+|(?=:))(:(?P<metadata>\d+|(?=:))(:(?P<soap>\d+))?)?)?)?)?)?')
131
+ _RE_COMPACT_NODE_SPEC: Pattern[str] = re.compile(r'((?P<protocol>https?)://)?(?P<host>[^:]+)(:(?P<repository>\d+|(?=:))(:(?P<configuration>\d+|(?=:))(:(?P<poller>\d+|(?=:))(:(?P<crawler>\d+|(?=:))(:(?P<metadata>\d+|(?=:))(:(?P<soap>\d+))?)?)?)?)?)?')
132
132
 
133
133
 
134
134
  #: A type for LOCKSS node specification strings.
135
- NodeSpecStr = str
135
+ CompactNodeSpec = str
136
136
 
137
137
 
138
- def _parse_node_spec_string(node_spec_string: NodeSpecStr) -> dict[str, str]:
139
- mat: Optional[Match[str]] = _RE_NODE_REFERENCE.fullmatch(node_spec_string)
138
+ def _parse_compact_node_spec(compact_node_spec: CompactNodeSpec) -> dict[str, str]:
139
+ mat: Optional[Match[str]] = _RE_COMPACT_NODE_SPEC.fullmatch(compact_node_spec)
140
140
  if mat is None:
141
- raise ValueError(f'Invalid node specification string: {node_spec_string}')
141
+ raise ValueError(f'Invalid compact node specification: {compact_node_spec}')
142
142
  d = dict(host=mat.group('host'))
143
143
  if prot := mat.group('protocol'):
144
144
  d['protocol'] = prot
@@ -153,7 +153,7 @@ def _parse_node_spec_string(node_spec_string: NodeSpecStr) -> dict[str, str]:
153
153
  d['type'] = NodeTypeEnum.V1.value
154
154
  d['ui'] = repo_or_ui
155
155
  else:
156
- raise ValueError(f'Invalid repository/UI port in node specification string: {repo_or_ui}')
156
+ raise ValueError(f'Invalid repository/UI port in compact node specification: {repo_or_ui}')
157
157
  else:
158
158
  # Assume V2
159
159
  d['type'] = NodeTypeEnum.V2.value
@@ -163,17 +163,17 @@ def _parse_node_spec_string(node_spec_string: NodeSpecStr) -> dict[str, str]:
163
163
  return d
164
164
 
165
165
 
166
- def _maybe_deserialize_node_spec_string(value: Any) -> Any:
167
- if isinstance(value, NodeSpecStr) and not value.startswith('{'):
168
- return _parse_node_spec_string(value)
166
+ def _maybe_deserialize_compact_node_spec(value: Any) -> Any:
167
+ if isinstance(value, CompactNodeSpec) and not value.startswith('{'):
168
+ return _parse_compact_node_spec(value)
169
169
  return value
170
170
 
171
171
 
172
172
  #: A type for LOCKSS node specifications, that also accepts a compact LOCKSS
173
- #: node specification string.
173
+ #: node specification.
174
174
  NodeSpec = Annotated[
175
175
  Annotated[Union[NodeSpec1, NodeSpec2], Field(discriminator='type')],
176
- BeforeValidator(_maybe_deserialize_node_spec_string)
176
+ BeforeValidator(_maybe_deserialize_compact_node_spec)
177
177
  ]
178
178
 
179
179