Skip to main content

BAS Metadata Library

Python library for generating metadata records.

Overview

The BAS Metadata Library is an underpinning library for other tools and applications to generate discovery and administrative level metadata records (describing products, services and other resources, and their management).

This library is intended to avoid duplicating complex and verbose encode/decoding logic across projects and ensure interoperability between and within systems.

The library supports a lossless, two-way, conversion between a Configuration Object (a python dict representing the fields/structure of a record for a standard) into its formal representation (typically an XML document)

The library also supports validating record configurations (via JSON Schemas) and formal representations (typically via XML XSDs).

Supported standards

Standard Implementation Status Library Namespace Introduced In Retired In
ISO 19115:2003 ISO 19139:2007 Supported bas_metadata_library.standards.iso_19115_0_v1 #46 🛡️ -
ISO 19115-2:2009 ISO 19139-2:2012 Supported bas_metadata_library.standards.iso_19115_2_v1 #50 🛡️ -
IEC 61174:2015 IEC 61174:2015 Retired - #139 🛡️ #266 🛡️
IEC PAS 61174:2021 IEC PAS 61174:2021 Retired - #139 🛡️ #266 🛡️

Supported profiles

Standard Profile Introduced In Status
ISO 19115 MAGIC Discovery Metadata V1 #250 Stable
ISO 19115 MAGIC Discovery Metadata V2 #250 Experimental
ISO 19115 MAGIC Administration Metadata V1 #250 Experimental

Supported configuration versions

Standard Profile Configuration Version Status Notes
IEC 61174:2015 - v1 Retired No longer supported
IEC PAS 61174:2021 - v1 Retired No longer supported
ISO 19115:2003 - v1 Retired Replaced by v2, no longer supported
ISO 19115:2003 - v2 Retired Replaced by v3, no longer supported
ISO 19115:2003 - v3 Retired Replaced by v4, no longer supported
ISO 19115:2003 - v4 Stable Currently supported version
ISO 19115-2:2009 - v1 Retired Replaced by v2, no longer supported
ISO 19115-2:2009 - v2 Retired Replaced by v3, no longer supported
ISO 19115-2:2009 - v3 Retired Replaced by v4, no longer supported
ISO 19115-2:2009 - v4 Stable Currently supported version
ISO 19115-2:2009 MAGIC Discovery Metadata V1 v1 Stable Currently supported version
ISO 19115-2:2009 MAGIC Discovery Metadata V2 v1 Experimental Next supported version
MAGIC Administration Metadata V1 (Content) - v1 Experimental Next supported version
ISO 19115-2:2009 MAGIC Administration Metadata V1 (Encoding) v1 Experimental Next supported version

Supported standards coverage

This library is limited to the standards, and subset of elements within these standards, needed for tools and use-cases within the British Antarctic Survey (BAS) and the NERC Polar Data Centre (UK PDC).

Standard Coverage Coverage Summary
ISO 19115:2003 Good All mandatory elements are supported with a good number of commonly used additional elements
ISO 19115-2:2009 Minimal No elements from this extension are supported, with the exception of the root element

Installation

Installed from PyPi:

$ pip install bas-metadata-library

Installation dependencies

This package depends on these OS level libraries for XML encoding and decoding:

  • libxml2
  • libxslt

This package depends on these OS level binaries for XML validation:

  • xmllint

These libraries may already be installed, or require additional OS packages:

Operating System Required Packages
Linux (Alpine) libxslt-dev, libxml2-utils
Linux (Debian) libxml2-utils

Usage

Encode an ISO 19115 metadata record

To generate an ISO 19115 metadata record from a Python record configuration and return it as an XML document:

from datetime import date

from bas_metadata_library.standards.iso_19115_2 import MetadataRecordConfigV4, MetadataRecord

# define a minimalish record configuration
minimalish_config = {
    "$schema": "https://metadata-resources.data.bas.ac.uk/bas-metadata-generator-configuration-schemas/v2/iso-19115-1-v4.json",
    "hierarchy_level": "product",
    "metadata": {
        "contacts": [{"organisation": {"name": "Mapping and Geographic Information Centre, British Antarctic Survey"}, "role": ["pointOfContact"]}],
        "date_stamp": date(2018, 10, 18),
    },
    "identification": {
        "title": {"value": "Test Record"},
        "dates": {"creation": {"date": date(2018, 1, 1), "date_precision": "year"}},
        "abstract": "Test Record for ISO 19115 metadata standard (no profile) with minimal (but not minimal) fields.",
        "character_set": "utf8",
        "language": "eng",
        "extents": [
            {
                "identifier": "bounding",
                "geographic": {
                    "bounding_box": {
                        "west_longitude": -45.61521,
                        "east_longitude": -27.04976,
                        "south_latitude": -68.1511,
                        "north_latitude": -54.30761,
                    }
                },
            },
        ],
    },
}

# encode metadata library specific Python config into a standards compliant XML document
config = MetadataRecordConfigV4(**minimal_config)
record = MetadataRecord(configuration=config)
document = record.generate_xml_document()

# output document
print(document.decode())

Decode an ISO 19115 metadata record

from pathlib import Path

from bas_metadata_library.standards.iso_19115_2 import MetadataRecord

# load XML document from a file
with Path(f"record.xml").open() as document_file:
    document = document_file.read()

# decode document into an metadata library specific Python config
record = MetadataRecord(record=document)
configuration = record.make_config()
config = configuration.config

# output config
print(config)

Implementation

See Implementation documentation.

Setup

See Setup documentation.

Development

See Development documentation.

Releases

See the Release Workflow for creating a new release.

Project maintainer

Mapping and Geographic Information Centre (MAGIC), British Antarctic Survey (BAS).

Project lead: @felnne.

Data protection

A Data Protection Impact Assessment (DPIA) does not apply to this project.

License

Copyright (c) 2019-2026 UK Research and Innovation (UKRI), British Antarctic Survey (BAS).

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for bas-metadata-library 0.18.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bas-metadata-library 0.18.1
File Size Uploaded Provenance Actions
bas_metadata_library-0.18.1.tar.gz 171.1 kB Without provenance Details for bas_metadata_library-0.18.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bas-metadata-library 0.18.1
File Interpreter ABI Platform Actions
bas_metadata_library-0.18.1-py3-none-any.whl Python 3 none any Details for bas_metadata_library-0.18.1-py3-none-any.whl

Total release size: 421.5 kB

Release files / bas_metadata_library-0.18.1.tar.gz

Download URL bas_metadata_library-0.18.1.tar.gz
Size 171.1 kB
Tags Source
SHA-256 checksum
How to use checksums
14d1b56749def35a5ded92977b28fbd54df0245e7db3419824b0bb2e3a836b22
BLAKE2b-256 checksum
How to use checksums
2870e1b706413e7e2f5413e717e9c7f0b198b14db81dbd427b28319d0c28d752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bas_metadata_library-0.18.1-py3-none-any.whl

Download URL bas_metadata_library-0.18.1-py3-none-any.whl
Size 250.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4bb5b096e3379fa3068936b4dab87d44c48218cd9df0e3321e6dd3cffc4001bf
BLAKE2b-256 checksum
How to use checksums
2578e7c50c9792495975cdfe1344bfffbf4e3327459b1a3f3b9a1223969d6943
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for bas-metadata-library 0.18.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.18.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page