Skip to main content

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.

Metadata

Release files for mets-to-edm 0.2.9

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

Source distribution (sdist)

Source distribution for mets-to-edm 0.2.9
File Size Uploaded
mets_to_edm-0.2.9.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mets-to-edm 0.2.9
File Interpreter ABI Platform
mets_to_edm-0.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 23.4 kB

Release files / mets_to_edm-0.2.9.tar.gz

Download URL mets_to_edm-0.2.9.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3f7c0934f2c4b3c04dc3d941c383041c93833d6d9c81d88b9aa7f10e63fed853
BLAKE2b-256 checksum
How to use checksums
434b18df32301aa86862d00fd4fd476307d9e346544451292932f86986ad0db9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.0 CPython/3.12.9 Linux/6.17.0-1022-azure

Release files / mets_to_edm-0.2.9-py3-none-any.whl

Download URL mets_to_edm-0.2.9-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
196c5ea463ffd68316e24204acea37c6a7b6933d83260931421076af1ce79d26
BLAKE2b-256 checksum
How to use checksums
a0a1450e62d043791f81b6bb6ff8c7d969d48b6f25e68ba52e2cd2cf048b1e98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.0 CPython/3.12.9 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

0.2.11

2 release files

0.2.10

2 release files

This release

0.2.9 This release

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

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