sdmxlib-cli 0.76.2__py3-none-any.whl → 0.78.0__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.
sdmxlib_cli/__init__.py CHANGED
@@ -25,6 +25,7 @@ from sdmxlib.bundle import (
25
25
  )
26
26
  from sdmxlib.model.dataflow import Dataflow
27
27
  from sdmxlib.model.urn import SdmxUrn
28
+ from sdmxlib.model.version import compliance
28
29
 
29
30
 
30
31
  class At(StrEnum):
@@ -89,15 +90,32 @@ def _source(text: str) -> ProviderInfo | str:
89
90
 
90
91
 
91
92
  def _flow(text: str) -> SdmxUrn[Dataflow]:
92
- """A dataflow as ``AGENCY:ID(VERSION)``, ``AGENCY:ID`` (latest), or a full URN."""
93
- if text.startswith("urn:"):
94
- return Dataflow.parse_urn(text)
95
- agency, _, rest = text.partition(":")
96
- flow_id, _, version = rest.partition("(")
97
- if not agency or not flow_id:
98
- msg = f"{text!r} is not AGENCY:ID(VERSION), AGENCY:ID or a dataflow URN"
93
+ """A dataflow as ``AGENCY:ID(VERSION)``, ``AGENCY:ID`` (latest), or a full URN.
94
+
95
+ Raises:
96
+ typer.BadParameter: Naming the accepted forms, for text that is none
97
+ of them: a malformed URN, agency or id, or a version that is
98
+ neither ``latest`` nor an SDMX version.
99
+ """
100
+ forms = "AGENCY:ID(VERSION), AGENCY:ID or a dataflow URN"
101
+ try:
102
+ if text.startswith("urn:"):
103
+ urn = Dataflow.parse_urn(text)
104
+ else:
105
+ agency, _, rest = text.partition(":")
106
+ flow_id, _, version = rest.partition("(")
107
+ if not agency or not flow_id:
108
+ msg = f"{text!r} is not {forms}"
109
+ raise typer.BadParameter(msg)
110
+ version = version.removesuffix(")") or "latest"
111
+ urn = Dataflow.urn_for(agency=agency, id=flow_id, version=version)
112
+ except sl.SdmxParseError as exc:
113
+ msg = f"{text!r} is not {forms}: {exc}"
114
+ raise typer.BadParameter(msg) from exc
115
+ if urn.version != "latest" and not compliance(urn.version):
116
+ msg = f"{text!r} is not {forms}: {urn.version!r} is neither latest nor an SDMX version"
99
117
  raise typer.BadParameter(msg)
100
- return Dataflow.urn_for(agency=agency, id=flow_id, version=version.rstrip(")") or "latest")
118
+ return urn
101
119
 
102
120
 
103
121
  @bundle.command("fetch")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdmxlib-cli
3
- Version: 0.76.2
3
+ Version: 0.78.0
4
4
  Summary: sdmxlib from the command line: check SDMX bundles
5
5
  Keywords: sdmx,statistics,metadata,cli
6
6
  Author: gabrielgellner
@@ -11,7 +11,7 @@ Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.14
14
- Requires-Dist: sdmxlib==0.76.2
14
+ Requires-Dist: sdmxlib==0.78.0
15
15
  Requires-Dist: typer>=0.27.3,<0.28
16
16
  Requires-Python: >=3.14
17
17
  Project-URL: Homepage, https://github.com/StatCat-Suite/sdmxlib
@@ -0,0 +1,6 @@
1
+ sdmxlib_cli/__init__.py,sha256=8RescQr-7QRIqxN-k4IXhb4zsRJ20cNxmkjo-p_FJ80,8533
2
+ sdmxlib_cli-0.78.0.dist-info/licenses/LICENSE,sha256=_NuWqbPQHlUavgc7x90LBENiUeYHgR_wRqGvobsCs5I,11345
3
+ sdmxlib_cli-0.78.0.dist-info/WHEEL,sha256=3NO1oYsF7mANFUWVdyEQLM-zmecczWWEmmF5rEbXrWk,80
4
+ sdmxlib_cli-0.78.0.dist-info/entry_points.txt,sha256=nni5NOVMshJOBOByM9CIsQ1jlf-XIJSbu6j1Jmy6bxw,45
5
+ sdmxlib_cli-0.78.0.dist-info/METADATA,sha256=tAuDii_l7TwH_VbpcPNm57TMHmsO8RroBhTcmtzyJlM,1679
6
+ sdmxlib_cli-0.78.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- sdmxlib_cli/__init__.py,sha256=jYP8mIomXYcqDM_fPa-AFkIkHYK7_H1s91E13eyep7c,7788
2
- sdmxlib_cli-0.76.2.dist-info/licenses/LICENSE,sha256=_NuWqbPQHlUavgc7x90LBENiUeYHgR_wRqGvobsCs5I,11345
3
- sdmxlib_cli-0.76.2.dist-info/WHEEL,sha256=3NO1oYsF7mANFUWVdyEQLM-zmecczWWEmmF5rEbXrWk,80
4
- sdmxlib_cli-0.76.2.dist-info/entry_points.txt,sha256=nni5NOVMshJOBOByM9CIsQ1jlf-XIJSbu6j1Jmy6bxw,45
5
- sdmxlib_cli-0.76.2.dist-info/METADATA,sha256=zN7dV2AIWiOKQK9xIxdMtFjI_fa7aI41kw8-wFgU6fE,1679
6
- sdmxlib_cli-0.76.2.dist-info/RECORD,,