Skip to main content

Modular mapping of METS/MODS data to EDM (Europeana Data Model), providing comprehensive transformation of METS/MODS XML structures into Pydantic-based EDM classes and properties.

Project description

mets_to_edm

mets_to_edm is a Python library for converting METS/MODS XML records into Europeana Data Model (EDM) records. It can be used both as a library and from the command line and has a basic Mapping that should work well for most cases. But the library also provides a flexible mapping layer to override certain parts.

Features

  • Converts METS/MODS XML to EDM using edmlib
  • Easily extensible: override mapping methods to customize output
  • CLI and Python API

Installation

Install via Poetry (recommended):

poetry install

Or with pip (if you have all dependencies):

pip install .

Usage

As a Python Library

from mets_to_edm import MetsToEdmMapper
from lxml import etree

# Parse your METS/MODS XML file
xml_tree = etree.parse("example.xml")

# Convert to an EDM record
edmlib_record = MetsToEdmMapper.process_record(xml_tree)

# Serialize to EDM XML
edm_xml = edmlib_record.serialize()
print(edm_xml)

From the Command Line

python -m mets_to_edm example.xml "Provider Name" [--data-provider "Data Provider"]
  • "Provider Name": the institution name to be filled in as edm:provider (the aggregator providing the data to europeana)
  • "Data Provider": the institution name to be filled in as edm:dataProvider (the Organisation where the data originates from). Optional as it will otherwise be extracted from the amdSec using XPath "mets:rightsMD/mets:mdWrap/mets:xmlData/dv:rights/dv:owner"

Customizing the Mapping

To change how specific fields are mapped, subclass MetsToEdmMapper and override the relevant class methods. For example, to change how titles are extracted: You can override any method such as:

  • get_titles
  • get_descriptions
  • get_publishers
  • get_types
  • get_languages
  • ...and more (see mets_to_edm/mapper.py for all available hooks)

Example: Overriding the Data Provider

class MyMapper(MetsToEdmMapper):
	@classmethod
	def get_data_provider(cls, dmd_sec, amd_sec, default=None):
		return "My Custom Data Provider"

# Usage:
# edmlib_record = MyCustomMapper.process_record(tree)

For more examples have a look at the examples directory.

Further Information

  • See the source code in mets_to_edm/mapper.py for all overridable methods and mapping logic.
  • For questions or contributions, open an issue or pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mets_to_edm-0.2.4.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mets_to_edm-0.2.4-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file mets_to_edm-0.2.4.tar.gz.

File metadata

  • Download URL: mets_to_edm-0.2.4.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.0 CPython/3.12.9 Linux/6.17.0-1010-azure

File hashes

Hashes for mets_to_edm-0.2.4.tar.gz
Algorithm Hash digest
SHA256 82c50ae8d8aa2c49ba31eb9dac5f892d48daea87d3fe3584727479b345daeb38
MD5 97b275e27c76b8ca2aa720532dfb982c
BLAKE2b-256 140f3ca6d9b1ee2f22844b67fad5e72356d16aafaef648877bd0ad1a97705f3f

See more details on using hashes here.

File details

Details for the file mets_to_edm-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: mets_to_edm-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.0 CPython/3.12.9 Linux/6.17.0-1010-azure

File hashes

Hashes for mets_to_edm-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 057581f3e531b8498b8d21f6cf5426e074e76e00e97f248a80f46e771c5a29a5
MD5 e6a6a7195d8c0dcb48bf14374d6d58cc
BLAKE2b-256 4a5d98bd7936184f5d0fa60c04831bc608ddce5ccf56bb00c0a38f8d52209b90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page