sdmxlib-cli 0.77.0__tar.gz → 0.79.0__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.
- {sdmxlib_cli-0.77.0 → sdmxlib_cli-0.79.0}/PKG-INFO +2 -2
- {sdmxlib_cli-0.77.0 → sdmxlib_cli-0.79.0}/pyproject.toml +5 -2
- {sdmxlib_cli-0.77.0 → sdmxlib_cli-0.79.0}/pyproject.toml.orig +7 -2
- sdmxlib_cli-0.79.0/src/sdmxlib_cli/EGM.md +71 -0
- {sdmxlib_cli-0.77.0 → sdmxlib_cli-0.79.0}/src/sdmxlib_cli/__init__.py +26 -8
- {sdmxlib_cli-0.77.0 → sdmxlib_cli-0.79.0}/LICENSE +0 -0
- {sdmxlib_cli-0.77.0 → sdmxlib_cli-0.79.0}/README.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdmxlib-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.79.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.
|
|
14
|
+
Requires-Dist: sdmxlib==0.79.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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sdmxlib-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.79.0"
|
|
4
4
|
description = "sdmxlib from the command line: check SDMX bundles"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -19,7 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python :: 3.14",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
-
"sdmxlib==0.
|
|
22
|
+
"sdmxlib==0.79.0",
|
|
23
23
|
"typer>=0.27.3,<0.28",
|
|
24
24
|
]
|
|
25
25
|
|
|
@@ -41,5 +41,8 @@ Changelog = "https://github.com/StatCat-Suite/sdmxlib/blob/main/CHANGELOG.md"
|
|
|
41
41
|
requires = ["uv_build>=0.13.0,<0.14.0"]
|
|
42
42
|
build-backend = "uv_build"
|
|
43
43
|
|
|
44
|
+
[tool.uv.build-backend]
|
|
45
|
+
wheel-exclude = ["**/EGM.md"]
|
|
46
|
+
|
|
44
47
|
[tool.uv.sources.sdmxlib]
|
|
45
48
|
workspace = true
|
|
@@ -3,7 +3,7 @@ name = "sdmxlib-cli"
|
|
|
3
3
|
# Locked to sdmxlib's version and released with it (GH-67): the release steps
|
|
4
4
|
# bump both and the pin below, and a test asserts the three agree, so the
|
|
5
5
|
# command can never be installed against an sdmxlib it was not tested with.
|
|
6
|
-
version = "0.
|
|
6
|
+
version = "0.79.0"
|
|
7
7
|
description = "sdmxlib from the command line: check SDMX bundles"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = "Apache-2.0"
|
|
@@ -22,7 +22,7 @@ classifiers = [
|
|
|
22
22
|
# A standalone install, so sdmxlib itself never depends on typer:
|
|
23
23
|
# `uv tool install sdmxlib-cli` gives an `sdmxlib` command.
|
|
24
24
|
dependencies = [
|
|
25
|
-
"sdmxlib==0.
|
|
25
|
+
"sdmxlib==0.79.0",
|
|
26
26
|
# Pre-1.0, so capped at the minor.
|
|
27
27
|
"typer>=0.27.3,<0.28",
|
|
28
28
|
]
|
|
@@ -41,5 +41,10 @@ Changelog = "https://github.com/StatCat-Suite/sdmxlib/blob/main/CHANGELOG.md
|
|
|
41
41
|
requires = ["uv_build>=0.13.0,<0.14.0"]
|
|
42
42
|
build-backend = "uv_build"
|
|
43
43
|
|
|
44
|
+
[tool.uv.build-backend]
|
|
45
|
+
# The EGM.md contracts describe the source for developers; the wheel carries
|
|
46
|
+
# the package alone. The sdist keeps them as part of the source.
|
|
47
|
+
wheel-exclude = ["**/EGM.md"]
|
|
48
|
+
|
|
44
49
|
[tool.uv.sources]
|
|
45
50
|
sdmxlib = { workspace = true }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# sdmxlib_cli
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `sdmxlib` command, a typer app shipped as the separate `sdmxlib-cli`
|
|
6
|
+
distribution so that `sdmxlib` itself never depends on typer (GH-67). Each
|
|
7
|
+
command is a thin wrapper over `sdmxlib.bundle`: the module parses arguments,
|
|
8
|
+
calls one library function, and prints its result. The library tests the
|
|
9
|
+
behaviour behind each command; `tests/unit/test_cli.py` tests the wrapping.
|
|
10
|
+
|
|
11
|
+
## Interface
|
|
12
|
+
|
|
13
|
+
- `app` — the root `typer.Typer`; the console script `sdmxlib = "sdmxlib_cli:app"`
|
|
14
|
+
in `cli/pyproject.toml`. It holds one sub-app, `bundle`.
|
|
15
|
+
- `sdmxlib bundle check PATH --at {publish,receive,open} [--expect EARLIER]` —
|
|
16
|
+
`check(path, *, at, expect)` calls `check_bundle(path, at=..., expect=...)`,
|
|
17
|
+
prints each finding and a summary line
|
|
18
|
+
(`<path>: N finding(s); checked ...`), and exits 1 when the report is not
|
|
19
|
+
`ok`, 0 otherwise. `--at` is required.
|
|
20
|
+
- `sdmxlib bundle fetch SOURCE FLOW PATH [--key] [--start] [--end]
|
|
21
|
+
[--structures-only] [--api 2.1] [--source-id]` — `fetch(...)` calls
|
|
22
|
+
`fetch_bundle` and prints `<path>/<token>: <bundle_id>, <counts>; token <token>`.
|
|
23
|
+
`PATH` must be absent or empty (`fetch_bundle` raises `FileExistsError`
|
|
24
|
+
otherwise); the publication lands in `<path>/<token>/` and its data files in
|
|
25
|
+
`<path>/data/`. `--api` and `--source-id` apply only to a URL `SOURCE`; a
|
|
26
|
+
provider carries its own API version.
|
|
27
|
+
- `sdmxlib bundle copy SOURCE DESTINATION [--tiers 1,2,3]` — `copy(...)` calls
|
|
28
|
+
`copy_bundle` and prints the destination, bundle id, token and file count.
|
|
29
|
+
- `sdmxlib bundle files MANIFEST [--tiers 1,2,3] [--manifest]` — `files(...)`
|
|
30
|
+
reads the manifest with `read_manifest` and prints `bundle_files(...)` one
|
|
31
|
+
path per line, for `rclone --files-from -` or azcopy; `--manifest` prints
|
|
32
|
+
only `<token>/bundle.manifest.json`.
|
|
33
|
+
- `At` — `StrEnum` of `--at`'s choices (`publish`, `receive`, `open`), mapped
|
|
34
|
+
to the library's `Profile` literals by `_PROFILES`.
|
|
35
|
+
- Private parsers: `_source(text)` (a `sl.Provider` by case-insensitive name,
|
|
36
|
+
or the text itself when it contains `://`), `_flow(text)` (`AGENCY:ID(VERSION)`,
|
|
37
|
+
`AGENCY:ID` meaning `latest`, or a `urn:` string, to `SdmxUrn[Dataflow]`),
|
|
38
|
+
`_tiers(text)` (comma-separated `1`/`2`/`3` to `list[Tier]`).
|
|
39
|
+
|
|
40
|
+
## Invariants
|
|
41
|
+
|
|
42
|
+
- Commands hold no logic of their own beyond argument parsing and printing;
|
|
43
|
+
behaviour changes belong in `sdmxlib.bundle`.
|
|
44
|
+
- A bad `SOURCE`, `FLOW` or tier raises `typer.BadParameter` naming the
|
|
45
|
+
accepted forms, so the CLI prints usage rather than a traceback. `_flow`
|
|
46
|
+
converts the library's `SdmxParseError` (a malformed URN, agency or id) and
|
|
47
|
+
refuses a version that is neither `latest` nor an SDMX version
|
|
48
|
+
(`model.version.compliance`), in either form (GH-265).
|
|
49
|
+
- `bundle files` accepts either a publication directory or a
|
|
50
|
+
`bundle.manifest.json` staged elsewhere (its parent is used). Its listing
|
|
51
|
+
leaves the manifest out and `--manifest` prints the manifest's path alone,
|
|
52
|
+
so a copy tool moves the manifest in a second step, after every other file.
|
|
53
|
+
- `cli/pyproject.toml`'s version and its `sdmxlib==` pin equal sdmxlib's
|
|
54
|
+
version; `test_the_cli_is_locked_to_sdmxlibs_version` asserts the three
|
|
55
|
+
agree, and `just` release steps bump them together.
|
|
56
|
+
- `cli/LICENSE` is byte-for-byte sdmxlib's licence (asserted by a test).
|
|
57
|
+
|
|
58
|
+
## Side Effects
|
|
59
|
+
|
|
60
|
+
- `check` and `files` read the bundle (manifest, files, DuckDB catalog) and
|
|
61
|
+
write nothing.
|
|
62
|
+
- `fetch` makes HTTP requests to the SDMX REST source and creates a new
|
|
63
|
+
publication directory under `PATH`.
|
|
64
|
+
- `copy` writes files to `DESTINATION` and the shared data directory beside
|
|
65
|
+
it, verifies them, and writes the manifest last.
|
|
66
|
+
- All commands write to stdout; `check` sets the process exit status.
|
|
67
|
+
|
|
68
|
+
## Verification
|
|
69
|
+
|
|
70
|
+
- Run: `uv run pytest tests/unit/test_cli.py`
|
|
71
|
+
- Full gate: `just ci`
|
|
@@ -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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
118
|
+
return urn
|
|
101
119
|
|
|
102
120
|
|
|
103
121
|
@bundle.command("fetch")
|
|
File without changes
|
|
File without changes
|