sdmxlib 0.89.0__tar.gz → 0.91.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-0.89.0 → sdmxlib-0.91.0}/PKG-INFO +1 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/pyproject.toml +1 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/pyproject.toml.orig +1 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/EGM.md +3 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/__init__.py +31 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/EGM.md +30 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/client.py +90 -10
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/registry.py +209 -2
- sdmxlib-0.91.0/src/sdmxlib/api/resources.py +79 -0
- sdmxlib-0.91.0/src/sdmxlib/api/structure_download.py +127 -0
- sdmxlib-0.91.0/src/sdmxlib/api/submit.py +214 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_overlay.py +1 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/EGM.md +9 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/__init__.py +34 -3
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_structure_dto.py +3 -4
- sdmxlib-0.91.0/src/sdmxlib/formats/structure_format.py +78 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/registry.py +9 -9
- sdmxlib-0.91.0/src/sdmxlib/migration/EGM.md +139 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/__init__.py +59 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_agencies.py +173 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_conflicts.py +58 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_fmr.py +253 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_fmr_refusals.py +313 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_hierarchies.py +152 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_plan.py +366 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_structure.py +378 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_types.py +255 -0
- sdmxlib-0.91.0/src/sdmxlib/migration/_versions.py +252 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/EGM.md +35 -6
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/__init__.py +15 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_items.py +20 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_rebind.py +1 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_refshape.py +36 -5
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/base.py +79 -42
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/category.py +2 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/codelist.py +2 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/concept.py +2 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/constraint.py +4 -4
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/datastructure.py +11 -10
- sdmxlib-0.91.0/src/sdmxlib/model/diff.py +186 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/hierarchy.py +3 -3
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/in_memory_registry.py +9 -9
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/mapping.py +8 -8
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/metadataset.py +2 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/metadatastructure.py +5 -5
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/organisation.py +25 -11
- sdmxlib-0.91.0/src/sdmxlib/model/rewrite.py +588 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/urn.py +22 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/validation.py +37 -11
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/valuelist.py +2 -2
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/version.py +20 -4
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_expr.py +3 -3
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/schema.py +1 -1
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/writers.py +2 -3
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/versions.py +2 -2
- sdmxlib-0.89.0/src/sdmxlib/model/version_rewrite.py +0 -274
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/LICENSE +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/README.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/_duckdb.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/_facet_types.xsd +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/_facets.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/_read_errors.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/_singleflight.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/_time.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/_freshness.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/federated.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/policy.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/providers.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/api/session.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/builders/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/builders/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/builders/contentconstraint.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/builders/metadata_annotation.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/data_store.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_availability.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_build.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_canonical.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_check.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_copy.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_fetch.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_finding.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_fingerprint.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_remote.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/_write.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/manifest.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/edition/overlay.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_arrow.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_attachment.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_coerce.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_index.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_positions.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_refuse.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/_tags.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/data_format.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/gaps.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/render.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_csv/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_csv/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_csv/reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_csv/writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_data_common.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_dto.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_header.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_losses.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_periods.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_resolve.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/_structure_ingest.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/data.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/data_v1.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/data_v2.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/metadata.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/structure_values.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json/writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json_1_0/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json_1_0/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_json_1_0/writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_allowed_children.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_closed_world.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_common.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_header.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_losses.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_v3_reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml/_v3_writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/_providers.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/_synthetic.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/namespaces.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml21/writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml30/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml30/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml30/metadata.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml30/namespaces.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml30/reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml30/writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml31/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml31/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml31/namespaces.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml31/reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/formats/sdmx_ml31/writer.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/_format.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/_reader.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/_routing.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/_rules.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/conformance.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/catalog-2.0.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/catalog.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/current.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/history.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/leaf.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/root-1.2.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/root.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/segment-header.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/inventory/schemas/segment-line.schema.json +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/_scan.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/data_store.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/engine.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/object_store.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/local/sql.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_binding.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_container.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_invariants.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_label_match.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_referenceable.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_resolvers.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_rules.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/_tree.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/annotations.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/binding.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/collections.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/convert.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/dataflow.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/errors.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/expr.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/header.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/istring.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/link.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/message.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/metadata_provision.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/metadataflow.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/period.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/provision.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/ref.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/registry.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/representation.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/rest_api.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/model/rollup.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/polars.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/py.typed +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_closure.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_common.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_compile.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_edges.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_execute.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_joins.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_plan.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_pushdown.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_rebase.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/_rest.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/accessors.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/observations.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/query.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/raw.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/query/schema.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/rest.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/session.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/sql.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/EGM.md +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/__init__.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_checked.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_columns.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_files.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_kinds.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_layout.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_manifest.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_parsed.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_projections.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_references.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_synthetic.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_tags.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/_trim.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/lazy.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/readers.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/storage/resolve.py +0 -0
- {sdmxlib-0.89.0 → sdmxlib-0.91.0}/src/sdmxlib/testing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdmxlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.91.0
|
|
4
4
|
Summary: SDMX for Python: structures, reference metadata and observation data, from REST, files or a local DuckDB store.
|
|
5
5
|
Keywords: sdmx,statistics,metadata,datastructure
|
|
6
6
|
Author: gabrielgellner
|
|
@@ -68,7 +68,7 @@ the subpackages share.
|
|
|
68
68
|
(`testing.py`): build a seeded synthetic edition that passes `check_edition`,
|
|
69
69
|
or take a `Shape` from an existing edition.
|
|
70
70
|
- `RewrittenVersion`, `VersionRewrite` and `strip_leading_zeros`
|
|
71
|
-
(`versions.py`): re-exported from `model.
|
|
71
|
+
(`versions.py`): re-exported from `model.rewrite` for
|
|
72
72
|
`add_all(rewrite_version=...)`.
|
|
73
73
|
- Subpackages:
|
|
74
74
|
- [`model/`](./model/EGM.md): the frozen attrs SDMX information model,
|
|
@@ -90,6 +90,8 @@ the subpackages share.
|
|
|
90
90
|
fingerprints.
|
|
91
91
|
- [`builders/`](./builders/EGM.md): availability constraints and DSD
|
|
92
92
|
metadata annotations, computed from an edition.
|
|
93
|
+
- [`migration/`](./migration/EGM.md): `sl.migration`, plan and apply a
|
|
94
|
+
2.1 → 3.x move of a structure message.
|
|
93
95
|
|
|
94
96
|
## Invariants
|
|
95
97
|
|
|
@@ -11,6 +11,9 @@ from sdmxlib.formats.data_format import DataFormat
|
|
|
11
11
|
from sdmxlib.formats.gaps import DroppedArtefact, Gap, dropped, unrepresentable
|
|
12
12
|
from sdmxlib.api.client import ResponseTooLargeError
|
|
13
13
|
from sdmxlib.api.registry import BearerToken, FmrRegistry, Resolve, RestRegistry
|
|
14
|
+
from sdmxlib.api.structure_download import StructureDownload, read_all_structures
|
|
15
|
+
from sdmxlib.api.submit import SubmissionNotHeldError, SubmissionReport, SubmissionResult
|
|
16
|
+
from sdmxlib.formats.structure_format import StructureFormat
|
|
14
17
|
from sdmxlib.data_store import DataStore, WriteSource
|
|
15
18
|
from sdmxlib.model.datastructure import ComponentRole
|
|
16
19
|
from sdmxlib.model.ref import short_urn as short_urn
|
|
@@ -19,7 +22,7 @@ from sdmxlib.model.rest_api import ApiVersion
|
|
|
19
22
|
from sdmxlib.model.rollup import AncestorMap
|
|
20
23
|
from sdmxlib.session import Session, SessionHook, ValueSet
|
|
21
24
|
from sdmxlib.query import RawSql, RawSqlError, schema
|
|
22
|
-
from sdmxlib import versions
|
|
25
|
+
from sdmxlib import migration, versions
|
|
23
26
|
from sdmxlib.versions import RewrittenVersion, VersionRewrite
|
|
24
27
|
from sdmxlib.query.accessors import ArtefactRow, CodeRow, HCodeRow, ReportedAttributeRow, q
|
|
25
28
|
from sdmxlib.query._compile import CompiledQuery
|
|
@@ -73,6 +76,7 @@ from sdmxlib.model.validation import (
|
|
|
73
76
|
SdmxParseError,
|
|
74
77
|
ValidationError,
|
|
75
78
|
ValidationIssue,
|
|
79
|
+
Deviation,
|
|
76
80
|
check_serialisable,
|
|
77
81
|
validate,
|
|
78
82
|
validate_references,
|
|
@@ -176,11 +180,19 @@ from sdmxlib.model import (
|
|
|
176
180
|
SourceValue,
|
|
177
181
|
item,
|
|
178
182
|
normalize_tag,
|
|
183
|
+
diff,
|
|
179
184
|
period_bounds,
|
|
180
185
|
period_range,
|
|
186
|
+
rewrite,
|
|
181
187
|
tag_alias,
|
|
188
|
+
UrnMap,
|
|
189
|
+
version_key,
|
|
182
190
|
Maintainable,
|
|
191
|
+
AnnotableArtefact,
|
|
192
|
+
IdentifiableArtefact,
|
|
183
193
|
MaintainableArtefact,
|
|
194
|
+
NameableArtefact,
|
|
195
|
+
OrganisationScheme,
|
|
184
196
|
MapDataType,
|
|
185
197
|
MapEndpoint,
|
|
186
198
|
Measure,
|
|
@@ -203,6 +215,7 @@ from sdmxlib.model import (
|
|
|
203
215
|
Ref,
|
|
204
216
|
Refusal,
|
|
205
217
|
RegistryReader,
|
|
218
|
+
SupportsGet,
|
|
206
219
|
Representation,
|
|
207
220
|
RepresentationMap,
|
|
208
221
|
SdmxRef,
|
|
@@ -245,6 +258,7 @@ __all__ = [
|
|
|
245
258
|
"AggPred",
|
|
246
259
|
"AmbiguousHierarchyError",
|
|
247
260
|
"AncestorMap",
|
|
261
|
+
"AnnotableArtefact",
|
|
248
262
|
"Annotation",
|
|
249
263
|
"AnnotationURL",
|
|
250
264
|
"Annotations",
|
|
@@ -303,6 +317,7 @@ __all__ = [
|
|
|
303
317
|
"DataflowEntry",
|
|
304
318
|
"DatePatternMap",
|
|
305
319
|
"Descending",
|
|
320
|
+
"Deviation",
|
|
306
321
|
"Dimension",
|
|
307
322
|
"DriftError",
|
|
308
323
|
"DriftIssue",
|
|
@@ -333,6 +348,7 @@ __all__ = [
|
|
|
333
348
|
"Hierarchy",
|
|
334
349
|
"HierarchyAssociation",
|
|
335
350
|
"ISOConceptReference",
|
|
351
|
+
"IdentifiableArtefact",
|
|
336
352
|
"ImRuleWarning",
|
|
337
353
|
"InMemoryRegistry",
|
|
338
354
|
"InclusionMode",
|
|
@@ -368,9 +384,11 @@ __all__ = [
|
|
|
368
384
|
"MetadataStructure",
|
|
369
385
|
"Metadataflow",
|
|
370
386
|
"MissingTagError",
|
|
387
|
+
"NameableArtefact",
|
|
371
388
|
"Num",
|
|
372
389
|
"ObsQuery",
|
|
373
390
|
"ObsRow",
|
|
391
|
+
"OrganisationScheme",
|
|
374
392
|
"OrganisationSchemeMap",
|
|
375
393
|
"OrganisationUnit",
|
|
376
394
|
"OrganisationUnitScheme",
|
|
@@ -429,9 +447,15 @@ __all__ = [
|
|
|
429
447
|
"StoreSchemaError",
|
|
430
448
|
"StoreSecret",
|
|
431
449
|
"Str",
|
|
450
|
+
"StructureDownload",
|
|
451
|
+
"StructureFormat",
|
|
432
452
|
"StructureMap",
|
|
433
453
|
"StructureMessage",
|
|
434
454
|
"StructureSet",
|
|
455
|
+
"SubmissionNotHeldError",
|
|
456
|
+
"SubmissionReport",
|
|
457
|
+
"SubmissionResult",
|
|
458
|
+
"SupportsGet",
|
|
435
459
|
"SupportsUrn",
|
|
436
460
|
"TimeBound",
|
|
437
461
|
"TimeDimension",
|
|
@@ -439,6 +463,7 @@ __all__ = [
|
|
|
439
463
|
"ToValueType",
|
|
440
464
|
"UnresolvedRef",
|
|
441
465
|
"Untyped",
|
|
466
|
+
"UrnMap",
|
|
442
467
|
"ValidationError",
|
|
443
468
|
"ValidationIssue",
|
|
444
469
|
"ValueItem",
|
|
@@ -451,10 +476,12 @@ __all__ = [
|
|
|
451
476
|
"WriteSource",
|
|
452
477
|
"artefact_urn",
|
|
453
478
|
"check_serialisable",
|
|
479
|
+
"diff",
|
|
454
480
|
"dropped",
|
|
455
481
|
"from_dict",
|
|
456
482
|
"item",
|
|
457
483
|
"len",
|
|
484
|
+
"migration",
|
|
458
485
|
"normalize_tag",
|
|
459
486
|
"parse",
|
|
460
487
|
"parse_components",
|
|
@@ -462,6 +489,8 @@ __all__ = [
|
|
|
462
489
|
"period_range",
|
|
463
490
|
"q",
|
|
464
491
|
"read",
|
|
492
|
+
"read_all_structures",
|
|
493
|
+
"rewrite",
|
|
465
494
|
"schema",
|
|
466
495
|
"serialize",
|
|
467
496
|
"tag_alias",
|
|
@@ -472,6 +501,7 @@ __all__ = [
|
|
|
472
501
|
"unrepresentable",
|
|
473
502
|
"validate",
|
|
474
503
|
"validate_references",
|
|
504
|
+
"version_key",
|
|
475
505
|
"versions",
|
|
476
506
|
"widen_key",
|
|
477
507
|
]
|
|
@@ -40,7 +40,32 @@ through `RestRegistry.query` (structures) and `RestRegistry.obs`
|
|
|
40
40
|
- `FmrRegistry` and `BearerToken` (`registry.py`): a `RestRegistry` for FMR.
|
|
41
41
|
`auth=` takes a `BearerToken`, sent as an `Authorization` header, or a
|
|
42
42
|
`(user, pass)` tuple, passed to httpx2. It always uses `api="2.1"` and
|
|
43
|
-
forwards only `HttpxTransportOptions`.
|
|
43
|
+
forwards only `HttpxTransportOptions`. `FmrRegistry.submit(msg, *, target,
|
|
44
|
+
action, granularity)` loads structures (GH-400): it checks the whole message
|
|
45
|
+
with `check_serialisable` for the `sl.migration.Target`, then posts each
|
|
46
|
+
artefact alone in `submission_order` (or the message whole) to the
|
|
47
|
+
submission URL, derived from a `/ws/public/` endpoint or given as
|
|
48
|
+
`submit_url=`, and returns a `SubmissionReport`.
|
|
49
|
+
- `RestRegistry.download_structures(resource, *, fmt, agency, id, version,
|
|
50
|
+
to)` and `download_all_structures(to, *, fmt, agency)` (`registry.py`,
|
|
51
|
+
GH-402): a structure resource's bytes as the registry sent them, every
|
|
52
|
+
version by default. `fmt` is a `StructureFormat`; an SDMX `Content-Type` is
|
|
53
|
+
held to it, and a generic one (`application/xml`) is checked by the body's
|
|
54
|
+
head (`structure_format.sniff`) before a byte is written. The whole copy
|
|
55
|
+
asks for every resource in `resources.py`, writes `<resource><suffix>`,
|
|
56
|
+
and records a `StructureDownload` per resource (`written` with size and
|
|
57
|
+
SHA-256, `none-held` for a 404, `refused` otherwise) in `downloads.json`.
|
|
58
|
+
- `read_all_structures(directory)` (`structure_download.py`, `sl.read_all_structures`):
|
|
59
|
+
such a copy read back as one `StructureMessage`, each written file parsed
|
|
60
|
+
not strict and merged, keeping every read's refusals, losses and
|
|
61
|
+
assumptions; an artefact in two files raises `ValueError`.
|
|
62
|
+
- `RESOURCES_21`, `RESOURCES_30` and `resources(api)` (`resources.py`): every
|
|
63
|
+
structure resource each SDMX-REST API names; the registry sweep reads them.
|
|
64
|
+
- `SubmissionReport`, `SubmissionResult`, `SubmissionNotHeldError`,
|
|
65
|
+
`submission_order`, `results_of` and `submit_url` (`submit.py`): a verdict per
|
|
66
|
+
artefact (`accepted`, `unchanged` for a 200 with no result, `refused` with
|
|
67
|
+
FMR's text); `verify(registry)` reads each accepted artefact back and raises
|
|
68
|
+
naming any not served.
|
|
44
69
|
- `FederatedRegistry` (`federated.py`): read-only router built from a
|
|
45
70
|
`routing` map (agency id to `RegistryReader`) and an optional `default`.
|
|
46
71
|
Provides `get`, `source_for`, `__contains__` and binding checks. `get`
|
|
@@ -110,7 +135,10 @@ through `RestRegistry.query` (structures) and `RestRegistry.obs`
|
|
|
110
135
|
|
|
111
136
|
## Side Effects
|
|
112
137
|
|
|
113
|
-
- Makes HTTP GETs through the single `httpx2.Client` that `SdmxClient` owns
|
|
138
|
+
- Makes HTTP GETs through the single `httpx2.Client` that `SdmxClient` owns,
|
|
139
|
+
and POSTs only from `FmrRegistry.submit`, which writes to the registry.
|
|
140
|
+
`download_structures` with `to`, and `download_all_structures`, write files;
|
|
141
|
+
a body refused for its format leaves none.
|
|
114
142
|
The client carries default headers, a timeout (30 s by default) and the
|
|
115
143
|
forwarded options.
|
|
116
144
|
- `get_artefact_if_changed` sends conditional requests: a 304 means unchanged
|
|
@@ -16,6 +16,7 @@ from sdmxlib.api._freshness import Freshness, read_freshness
|
|
|
16
16
|
from sdmxlib.api.policy import RegistryUnavailable
|
|
17
17
|
from sdmxlib.formats import parse
|
|
18
18
|
from sdmxlib.formats.data_format import DataFormat
|
|
19
|
+
from sdmxlib.formats.structure_format import StructureFormat, sniff
|
|
19
20
|
from sdmxlib.model.message import StructureMessage
|
|
20
21
|
from sdmxlib.model.rest_api import ApiVersion
|
|
21
22
|
|
|
@@ -176,7 +177,7 @@ def _version_parts(version: str) -> tuple[int, ...]:
|
|
|
176
177
|
return tuple(parts)
|
|
177
178
|
|
|
178
179
|
|
|
179
|
-
def _check_content_type(response: httpx2.Response, fmt: DataFormat, *, url: str) -> None:
|
|
180
|
+
def _check_content_type(response: httpx2.Response, fmt: DataFormat | StructureFormat, *, url: str) -> None:
|
|
180
181
|
"""Refuse a response that is not the format that was asked for.
|
|
181
182
|
|
|
182
183
|
Without this the format argument is decorative — which is precisely the
|
|
@@ -216,6 +217,31 @@ def _check_content_type(response: httpx2.Response, fmt: DataFormat, *, url: str)
|
|
|
216
217
|
raise ValueError(msg)
|
|
217
218
|
|
|
218
219
|
|
|
220
|
+
#: How much of a structure body `_check_structure_head` reads to sniff its format.
|
|
221
|
+
_HEAD = 4096
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _check_structure_head(response: httpx2.Response, head: bytes, fmt: StructureFormat, *, url: str) -> None:
|
|
225
|
+
"""Refuse a structure body that is not the format asked for.
|
|
226
|
+
|
|
227
|
+
An SDMX ``Content-Type`` is held to `fmt` as `_check_content_type` holds a
|
|
228
|
+
data download. A generic one (``application/xml``, ``application/json``,
|
|
229
|
+
which FMR sends for every structure format) says nothing about the version,
|
|
230
|
+
so the body's first bytes are read instead (`structure_format.sniff`).
|
|
231
|
+
"""
|
|
232
|
+
header = (response.headers.get("content-type") or "").partition(";")[0].strip().lower()
|
|
233
|
+
if "vnd.sdmx" in header:
|
|
234
|
+
_check_content_type(response, fmt, url=url)
|
|
235
|
+
return
|
|
236
|
+
found = sniff(head)
|
|
237
|
+
if found != fmt.sniffed:
|
|
238
|
+
msg = (
|
|
239
|
+
f"Asked for {fmt.media_type!r} but the body is {found or 'not SDMX'!s} "
|
|
240
|
+
f"under {response.headers.get('content-type')!r}: the provider ignored `Accept`. URL: {url}"
|
|
241
|
+
)
|
|
242
|
+
raise ValueError(msg)
|
|
243
|
+
|
|
244
|
+
|
|
219
245
|
def _require_csv(response: httpx2.Response, *, accept: str, url: str) -> None:
|
|
220
246
|
"""Refuse an observation fetch's response that is not CSV (GH-50).
|
|
221
247
|
|
|
@@ -383,6 +409,51 @@ class SdmxClient:
|
|
|
383
409
|
|
|
384
410
|
# ── URL building ──────────────────────────────────────────────────────────
|
|
385
411
|
|
|
412
|
+
def structure_query_url(self, resource: str, agency: str = "all", id: str = "all", version: str = "all") -> str:
|
|
413
|
+
"""The REST URL for `resource`'s artefacts, ``all`` meaning every agency, id or version.
|
|
414
|
+
|
|
415
|
+
On 3.0 ``all`` is spelled ``*`` and ``latest`` ``~``; on 2.1 both are
|
|
416
|
+
written as given.
|
|
417
|
+
"""
|
|
418
|
+
if not self._v3:
|
|
419
|
+
return f"{self._endpoint}/{resource}/{agency}/{id}/{version}"
|
|
420
|
+
spelled = [{"all": "*", "latest": "~"}.get(part, part) for part in (agency, id, version)]
|
|
421
|
+
return f"{self._endpoint}/structure/{resource}/{'/'.join(spelled)}"
|
|
422
|
+
|
|
423
|
+
def download_structures(self, url: str, *, fmt: StructureFormat, to: Path | None = None) -> bytes | None:
|
|
424
|
+
"""Fetch a structure query's body in `fmt`, unparsed; streamed to `to` when given.
|
|
425
|
+
|
|
426
|
+
The body's format is checked before a byte is written
|
|
427
|
+
(`_check_structure_head`), so a refused download leaves no file.
|
|
428
|
+
|
|
429
|
+
Returns:
|
|
430
|
+
The body, or None when it went to `to`.
|
|
431
|
+
|
|
432
|
+
Raises:
|
|
433
|
+
httpx2.HTTPStatusError: For a status other than 2xx; a 404 is
|
|
434
|
+
SDMX-REST's "no results".
|
|
435
|
+
ValueError: If the body is not the format asked for.
|
|
436
|
+
"""
|
|
437
|
+
headers = {"Accept": fmt.media_type}
|
|
438
|
+
with self._reaching(url), self._client.stream("GET", url, headers=headers) as response:
|
|
439
|
+
if not response.is_success:
|
|
440
|
+
response.read()
|
|
441
|
+
_raise_for_status(response, url=url)
|
|
442
|
+
chunks = response.iter_bytes()
|
|
443
|
+
head = b""
|
|
444
|
+
for chunk in chunks:
|
|
445
|
+
head += chunk
|
|
446
|
+
if len(head) >= _HEAD:
|
|
447
|
+
break
|
|
448
|
+
_check_structure_head(response, head, fmt, url=url)
|
|
449
|
+
if to is None:
|
|
450
|
+
return head + b"".join(chunks)
|
|
451
|
+
with to.open("wb") as handle:
|
|
452
|
+
handle.write(head)
|
|
453
|
+
for chunk in chunks:
|
|
454
|
+
handle.write(chunk)
|
|
455
|
+
return None
|
|
456
|
+
|
|
386
457
|
def _resource_url(
|
|
387
458
|
self,
|
|
388
459
|
resource: str,
|
|
@@ -420,11 +491,6 @@ class SdmxClient:
|
|
|
420
491
|
"""
|
|
421
492
|
return "3.0" if self._v3 else "2.1"
|
|
422
493
|
|
|
423
|
-
@property
|
|
424
|
-
def _parse_version(self) -> str:
|
|
425
|
-
"""Format version string passed to the parser."""
|
|
426
|
-
return "3.0" if self._v3 else "2.1"
|
|
427
|
-
|
|
428
494
|
# ── HTTP methods ──────────────────────────────────────────────────────────
|
|
429
495
|
|
|
430
496
|
def get_artefact(
|
|
@@ -522,8 +588,10 @@ class SdmxClient:
|
|
|
522
588
|
return NOT_MODIFIED
|
|
523
589
|
_raise_for_status(response, url=url)
|
|
524
590
|
# Not strict: one refused artefact must not cost the rest of a
|
|
525
|
-
# registry's document (#419). The refusals ride on the message.
|
|
526
|
-
|
|
591
|
+
# registry's document (#419). The refusals ride on the message. The
|
|
592
|
+
# version is read from the document: FMR 12.5.0 answers a 2.1 path with
|
|
593
|
+
# SDMX-ML 3.0 for some artefacts, which a 2.1 hint read as empty.
|
|
594
|
+
msg = parse(response.content, strict=False)
|
|
527
595
|
if not isinstance(msg, StructureMessage):
|
|
528
596
|
err = f"Expected StructureMessage from structure endpoint, got {type(msg).__name__}"
|
|
529
597
|
raise TypeError(err)
|
|
@@ -546,8 +614,10 @@ class SdmxClient:
|
|
|
546
614
|
response = self._client.get(url, params=params)
|
|
547
615
|
_raise_for_status(response, url=url)
|
|
548
616
|
# Not strict: one refused artefact must not cost the rest of a
|
|
549
|
-
# registry's document (#419). The refusals ride on the message.
|
|
550
|
-
|
|
617
|
+
# registry's document (#419). The refusals ride on the message. The
|
|
618
|
+
# version is read from the document: FMR 12.5.0 answers a 2.1 path with
|
|
619
|
+
# SDMX-ML 3.0 for some artefacts, which a 2.1 hint read as empty.
|
|
620
|
+
msg = parse(response.content, strict=False)
|
|
551
621
|
if not isinstance(msg, StructureMessage):
|
|
552
622
|
err = f"Expected StructureMessage from structure endpoint, got {type(msg).__name__}"
|
|
553
623
|
raise TypeError(err)
|
|
@@ -606,6 +676,16 @@ class SdmxClient:
|
|
|
606
676
|
_require_csv(response, accept=self._csv_media_type, url=url)
|
|
607
677
|
return response.content
|
|
608
678
|
|
|
679
|
+
def post_structures(self, url: str, body: bytes, *, action: str) -> httpx2.Response:
|
|
680
|
+
"""POST a structure document to a registry's submission *url*, with its ``ACTION``.
|
|
681
|
+
|
|
682
|
+
Through this client, so the caller's auth and transport options apply.
|
|
683
|
+
The response is returned whatever its status: a registry refuses in
|
|
684
|
+
its body, which the caller reads (`api.submit.results_of`).
|
|
685
|
+
"""
|
|
686
|
+
headers = {"ACTION": action.upper(), "Content-Type": "application/xml", "Accept": "application/xml"}
|
|
687
|
+
return self._client.post(url, content=body, headers=headers)
|
|
688
|
+
|
|
609
689
|
def stream_data_at(self, path: str, params: Mapping[str, str], *, to: Path) -> None:
|
|
610
690
|
"""Stream an already-built data request straight to a file.
|
|
611
691
|
|
|
@@ -8,15 +8,30 @@ from pathlib import Path
|
|
|
8
8
|
from typing import Literal, Never, Self, Unpack, cast, overload
|
|
9
9
|
|
|
10
10
|
import attrs
|
|
11
|
+
import httpx2
|
|
12
|
+
from lxml import etree
|
|
11
13
|
|
|
14
|
+
from sdmxlib import migration
|
|
12
15
|
from sdmxlib._read_errors import reading_csv
|
|
13
16
|
from sdmxlib._singleflight import SingleFlight
|
|
14
17
|
from sdmxlib.api.client import NOT_MODIFIED, HttpxAuthOption, HttpxOptions, HttpxTransportOptions, SdmxClient
|
|
15
18
|
from sdmxlib.api.providers import ProviderInfo
|
|
19
|
+
from sdmxlib.api.resources import resources
|
|
16
20
|
from sdmxlib.api.session import Completeness, Session, completeness_of
|
|
21
|
+
from sdmxlib.api.structure_download import DownloadStatus, StructureDownload, write_manifest, written
|
|
22
|
+
from sdmxlib.api.submit import (
|
|
23
|
+
SubmissionReport,
|
|
24
|
+
SubmissionResult,
|
|
25
|
+
results_of,
|
|
26
|
+
submission_order,
|
|
27
|
+
submit_url,
|
|
28
|
+
)
|
|
17
29
|
from sdmxlib.formats import parse as _parse
|
|
30
|
+
from sdmxlib.formats import serialize
|
|
18
31
|
from sdmxlib.formats.data_format import DataFormat
|
|
32
|
+
from sdmxlib.formats.gaps import dropped
|
|
19
33
|
from sdmxlib.formats.sdmx_json.data import read_observations
|
|
34
|
+
from sdmxlib.formats.structure_format import StructureFormat
|
|
20
35
|
from sdmxlib.local._scan import resolve_flow, scan_csv_into, scan_frame_into
|
|
21
36
|
from sdmxlib.local.data_store import DuckDBDataStore, column_types
|
|
22
37
|
from sdmxlib.local.registry import LocalRegistry
|
|
@@ -31,7 +46,7 @@ from sdmxlib.model.message import StructureMessage
|
|
|
31
46
|
from sdmxlib.model.provision import ProvisionAgreement
|
|
32
47
|
from sdmxlib.model.ref import Ref, SupportsUrn, artefact_urn, target_urn
|
|
33
48
|
from sdmxlib.model.urn import SdmxUrn
|
|
34
|
-
from sdmxlib.model.validation import SdmxConformanceError
|
|
49
|
+
from sdmxlib.model.validation import SdmxConformanceError, check_serialisable
|
|
35
50
|
from sdmxlib.query._closure import closure, detail_for, reached_columns, references_for
|
|
36
51
|
from sdmxlib.query._common import canonical_key
|
|
37
52
|
from sdmxlib.query._execute import fetch_into
|
|
@@ -140,7 +155,7 @@ def _references_for(*, resolve: Resolve) -> str:
|
|
|
140
155
|
return ",".join(sorted(_to_references(t) for t in resolve))
|
|
141
156
|
|
|
142
157
|
|
|
143
|
-
def _check_suffix(destination: Path, fmt: DataFormat) -> None:
|
|
158
|
+
def _check_suffix(destination: Path, fmt: DataFormat | StructureFormat) -> None:
|
|
144
159
|
"""Refuse a destination whose extension contradicts the format.
|
|
145
160
|
|
|
146
161
|
Not inference — the format has already been chosen. This catches the
|
|
@@ -159,6 +174,16 @@ def _check_suffix(destination: Path, fmt: DataFormat) -> None:
|
|
|
159
174
|
raise ValueError(msg)
|
|
160
175
|
|
|
161
176
|
|
|
177
|
+
def _error_reason(response: httpx2.Response) -> str:
|
|
178
|
+
"""The text of a registry's error message, or its status line."""
|
|
179
|
+
try:
|
|
180
|
+
root = etree.fromstring(response.content)
|
|
181
|
+
except etree.XMLSyntaxError:
|
|
182
|
+
return f"HTTP {response.status_code}: {response.text[:300]}"
|
|
183
|
+
texts = [t.text.strip() for t in root.iter("{*}Text") if t.text and t.text.strip()]
|
|
184
|
+
return texts[0] if texts else f"HTTP {response.status_code}"
|
|
185
|
+
|
|
186
|
+
|
|
162
187
|
class RestRegistry:
|
|
163
188
|
"""Connection to an SDMX REST endpoint.
|
|
164
189
|
|
|
@@ -1030,6 +1055,125 @@ class RestRegistry:
|
|
|
1030
1055
|
raise RuntimeError(msg)
|
|
1031
1056
|
return body
|
|
1032
1057
|
|
|
1058
|
+
@overload
|
|
1059
|
+
def download_structures(
|
|
1060
|
+
self,
|
|
1061
|
+
resource: str,
|
|
1062
|
+
*,
|
|
1063
|
+
fmt: StructureFormat,
|
|
1064
|
+
agency: str = "all",
|
|
1065
|
+
id: str = "all",
|
|
1066
|
+
version: str = "all",
|
|
1067
|
+
to: None = None,
|
|
1068
|
+
) -> bytes: ...
|
|
1069
|
+
|
|
1070
|
+
@overload
|
|
1071
|
+
def download_structures(
|
|
1072
|
+
self,
|
|
1073
|
+
resource: str,
|
|
1074
|
+
*,
|
|
1075
|
+
fmt: StructureFormat,
|
|
1076
|
+
agency: str = "all",
|
|
1077
|
+
id: str = "all",
|
|
1078
|
+
version: str = "all",
|
|
1079
|
+
to: Path | str,
|
|
1080
|
+
) -> Path: ...
|
|
1081
|
+
|
|
1082
|
+
def download_structures(
|
|
1083
|
+
self,
|
|
1084
|
+
resource: str,
|
|
1085
|
+
*,
|
|
1086
|
+
fmt: StructureFormat,
|
|
1087
|
+
agency: str = "all",
|
|
1088
|
+
id: str = "all",
|
|
1089
|
+
version: str = "all",
|
|
1090
|
+
to: Path | str | None = None,
|
|
1091
|
+
) -> bytes | Path:
|
|
1092
|
+
"""Fetch a structure resource exactly as the registry sends it.
|
|
1093
|
+
|
|
1094
|
+
`download`'s rules for structures: the format is asked for and never
|
|
1095
|
+
inferred, the body's format is checked, and nothing parses it. The
|
|
1096
|
+
version defaults to ``all``: a registry reads a bare query as
|
|
1097
|
+
``latest``, which misses every older version it holds.
|
|
1098
|
+
|
|
1099
|
+
reg.download_structures("codelist", fmt=sl.StructureFormat.SDMX_ML_2_1, to="codelist.xml")
|
|
1100
|
+
|
|
1101
|
+
Args:
|
|
1102
|
+
resource: The REST resource, such as ``"codelist"``
|
|
1103
|
+
(`sdmxlib.api.resources`).
|
|
1104
|
+
fmt: The format to ask for, sent as ``Accept``.
|
|
1105
|
+
agency: The maintainer, or ``"all"``.
|
|
1106
|
+
id: The artefact id, or ``"all"``.
|
|
1107
|
+
version: The version, ``"all"`` or ``"latest"``.
|
|
1108
|
+
to: Destination file; the body is streamed there.
|
|
1109
|
+
|
|
1110
|
+
Returns:
|
|
1111
|
+
The body, or the `Path` written.
|
|
1112
|
+
|
|
1113
|
+
Raises:
|
|
1114
|
+
httpx2.HTTPStatusError: For a status other than 2xx; a 404 means
|
|
1115
|
+
the registry holds none.
|
|
1116
|
+
ValueError: If `to`'s extension contradicts `fmt`, or the body is
|
|
1117
|
+
not the format asked for. No file is left behind.
|
|
1118
|
+
"""
|
|
1119
|
+
url = self._client.structure_query_url(resource, agency, id, version)
|
|
1120
|
+
destination = Path(to) if to is not None else None
|
|
1121
|
+
if destination is not None:
|
|
1122
|
+
_check_suffix(destination, fmt)
|
|
1123
|
+
body = self._client.download_structures(url, fmt=fmt, to=destination)
|
|
1124
|
+
if destination is not None:
|
|
1125
|
+
return destination
|
|
1126
|
+
if body is None: # pragma: no cover - the client returns bytes without `to`
|
|
1127
|
+
msg = "download_structures returned no body for an in-memory download"
|
|
1128
|
+
raise RuntimeError(msg)
|
|
1129
|
+
return body
|
|
1130
|
+
|
|
1131
|
+
def download_all_structures(
|
|
1132
|
+
self, to: Path | str, *, fmt: StructureFormat, agency: str = "all"
|
|
1133
|
+
) -> tuple[StructureDownload, ...]:
|
|
1134
|
+
"""Copy every structure resource the registry's API names into a directory, byte for byte.
|
|
1135
|
+
|
|
1136
|
+
One query per resource (`sdmxlib.api.resources`), every version of
|
|
1137
|
+
every artefact, each written as ``<resource><suffix>``. A 404 is
|
|
1138
|
+
recorded as holding none and anything else that is not the format
|
|
1139
|
+
asked for as refused, so one resource a registry does not serve does
|
|
1140
|
+
not stop the copy. The records also go to ``downloads.json``.
|
|
1141
|
+
|
|
1142
|
+
for record in reg.download_all_structures("copy/", fmt=sl.StructureFormat.SDMX_ML_2_1):
|
|
1143
|
+
print(record.resource, record.status)
|
|
1144
|
+
|
|
1145
|
+
Args:
|
|
1146
|
+
to: The directory, created if absent.
|
|
1147
|
+
fmt: The format to ask for.
|
|
1148
|
+
agency: The maintainer, or ``"all"``.
|
|
1149
|
+
|
|
1150
|
+
Returns:
|
|
1151
|
+
One `StructureDownload` per resource, in API order.
|
|
1152
|
+
"""
|
|
1153
|
+
directory = Path(to)
|
|
1154
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
1155
|
+
records: list[StructureDownload] = []
|
|
1156
|
+
for resource in resources(self._client.api):
|
|
1157
|
+
url = self._client.structure_query_url(resource, agency)
|
|
1158
|
+
path = directory / f"{resource}{fmt.suffix}"
|
|
1159
|
+
try:
|
|
1160
|
+
self._client.download_structures(url, fmt=fmt, to=path)
|
|
1161
|
+
except httpx2.HTTPStatusError as error:
|
|
1162
|
+
status = error.response.status_code
|
|
1163
|
+
kind: DownloadStatus = "none-held" if status == httpx2.codes.NOT_FOUND else "refused"
|
|
1164
|
+
reason = None if kind == "none-held" else _error_reason(error.response)
|
|
1165
|
+
records.append(
|
|
1166
|
+
StructureDownload(resource=resource, url=url, status=kind, http_status=status, reason=reason)
|
|
1167
|
+
)
|
|
1168
|
+
continue
|
|
1169
|
+
except ValueError as error:
|
|
1170
|
+
path.unlink(missing_ok=True)
|
|
1171
|
+
records.append(StructureDownload(resource=resource, url=url, status="refused", reason=str(error)))
|
|
1172
|
+
continue
|
|
1173
|
+
records.append(written(resource, url, path))
|
|
1174
|
+
write_manifest(directory, records)
|
|
1175
|
+
return tuple(records)
|
|
1176
|
+
|
|
1033
1177
|
def obs(self, flow: Dataflow | Ref[Dataflow] | SdmxUrn[Dataflow]) -> ObsQuery:
|
|
1034
1178
|
"""A lazy query over this dataflow's observations, served over HTTP.
|
|
1035
1179
|
|
|
@@ -1332,6 +1476,9 @@ class FmrRegistry(RestRegistry):
|
|
|
1332
1476
|
...
|
|
1333
1477
|
with sl.FmrRegistry(auth=("user", "pass")) as reg:
|
|
1334
1478
|
...
|
|
1479
|
+
|
|
1480
|
+
`submit` loads structures into the registry. Its URL is derived
|
|
1481
|
+
from a ``/ws/public/`` endpoint, or given as ``submit_url``.
|
|
1335
1482
|
"""
|
|
1336
1483
|
|
|
1337
1484
|
def __init__(
|
|
@@ -1339,6 +1486,7 @@ class FmrRegistry(RestRegistry):
|
|
|
1339
1486
|
endpoint: str = SDMX_GLOBAL_REGISTRY,
|
|
1340
1487
|
*,
|
|
1341
1488
|
auth: tuple[str, str] | BearerToken | None = None,
|
|
1489
|
+
submit_url: str | None = None,
|
|
1342
1490
|
timeout: float = 30.0,
|
|
1343
1491
|
id: str | None = None,
|
|
1344
1492
|
store: LocalRegistry | None = None,
|
|
@@ -1358,6 +1506,8 @@ class FmrRegistry(RestRegistry):
|
|
|
1358
1506
|
headers["Authorization"] = f"Bearer {auth.token}"
|
|
1359
1507
|
elif isinstance(auth, tuple):
|
|
1360
1508
|
auth_option["auth"] = auth
|
|
1509
|
+
self._endpoint = endpoint
|
|
1510
|
+
self._submit_url = submit_url
|
|
1361
1511
|
# The SDMX Global Registry currently serves 2.1 format responses.
|
|
1362
1512
|
super().__init__(
|
|
1363
1513
|
endpoint,
|
|
@@ -1369,3 +1519,60 @@ class FmrRegistry(RestRegistry):
|
|
|
1369
1519
|
**kwargs,
|
|
1370
1520
|
**auth_option,
|
|
1371
1521
|
)
|
|
1522
|
+
|
|
1523
|
+
def submit(
|
|
1524
|
+
self,
|
|
1525
|
+
msg: StructureMessage,
|
|
1526
|
+
*,
|
|
1527
|
+
target: migration.Target | None = None,
|
|
1528
|
+
action: Literal["replace", "append", "delete"] = "replace",
|
|
1529
|
+
granularity: Literal["artefact", "message"] = "artefact",
|
|
1530
|
+
) -> SubmissionReport:
|
|
1531
|
+
"""Load *msg*'s structures into the registry, with its verdict on each.
|
|
1532
|
+
|
|
1533
|
+
The whole message is checked as writable for *target* first, so a
|
|
1534
|
+
message the format refuses never leaves the machine. Then each
|
|
1535
|
+
artefact is written alone and sent in `submission_order`, so the
|
|
1536
|
+
registry's verdict names every artefact rather than the first problem
|
|
1537
|
+
in an atomic message; ``granularity="message"`` sends one document.
|
|
1538
|
+
An artefact the format leaves out (`formats.gaps.dropped`, such as a
|
|
1539
|
+
StructureSet in 3.0) is not sent, and has no result.
|
|
1540
|
+
|
|
1541
|
+
Args:
|
|
1542
|
+
msg: The structures to load.
|
|
1543
|
+
target: The format and deviations to write
|
|
1544
|
+
(`sl.migration.Target`); SDMX-ML 3.0 by default.
|
|
1545
|
+
`Target.fmr("12.5.0")` writes what FMR accepts beyond the XSD.
|
|
1546
|
+
action: ``"replace"``, ``"append"`` or ``"delete"``.
|
|
1547
|
+
granularity: ``"artefact"``, one POST each, or ``"message"``.
|
|
1548
|
+
|
|
1549
|
+
Returns:
|
|
1550
|
+
A verdict per artefact sent. `SubmissionReport.verify` reads the
|
|
1551
|
+
accepted ones back.
|
|
1552
|
+
|
|
1553
|
+
Raises:
|
|
1554
|
+
ValidationError: If the message cannot be written for *target*.
|
|
1555
|
+
ValueError: If no submission URL is known (`submit_url=`).
|
|
1556
|
+
|
|
1557
|
+
Example:
|
|
1558
|
+
with sl.FmrRegistry(url, auth=("root", "password")) as fmr:
|
|
1559
|
+
report = fmr.submit(migrated, target=sl.migration.Target.fmr("12.5.0"))
|
|
1560
|
+
report.verify(fmr)
|
|
1561
|
+
"""
|
|
1562
|
+
chosen = target or migration.Target(version="3.0")
|
|
1563
|
+
url = self._submit_url or submit_url(self._endpoint)
|
|
1564
|
+
check_serialisable(msg, version=chosen.version, allow=chosen.allow)
|
|
1565
|
+
if granularity == "message":
|
|
1566
|
+
gone = {drop.urn for drop in dropped(msg, chosen.version)}
|
|
1567
|
+
sent = [str(artefact_urn(a)) for a in msg.all_artefacts() if str(artefact_urn(a)) not in gone]
|
|
1568
|
+
body = serialize(msg, version=chosen.version, validate=False)
|
|
1569
|
+
return SubmissionReport(results_of(self._client.post_structures(url, body, action=action), sent))
|
|
1570
|
+
gone = {drop.urn for drop in dropped(msg, chosen.version)}
|
|
1571
|
+
results: list[SubmissionResult] = []
|
|
1572
|
+
for artefact in submission_order(msg):
|
|
1573
|
+
if str(artefact_urn(artefact)) in gone:
|
|
1574
|
+
continue
|
|
1575
|
+
body = serialize(StructureMessage.containing(artefact), version=chosen.version, validate=False)
|
|
1576
|
+
response = self._client.post_structures(url, body, action=action)
|
|
1577
|
+
results.extend(results_of(response, [str(artefact_urn(artefact))]))
|
|
1578
|
+
return SubmissionReport(tuple(results))
|