Skip to main content

Python implementation of CCMM (Czech Core Metadata Model) standard

Project description

pyCCMM - Python CCMM Metadata Handler

Python parser and metadata generator for Czech Core Metadata Model (CCMM).

Installation

pip install -r requirements.txt

Usage

Basic usage

from pyccmm import CCMMHandler

# Initialize handler (uses bundled CCMM schemas)
handler = CCMMHandler()

# Set basic required fields
handler.set_title("My dataset")
handler.set_publication_year(2024)

# Add identifier
handler.add_identifier("12345", "DOI")

# Add description
handler.add_description("Dataset description")

# Validation
if handler.is_valid():
    print("Dataset is valid!")
    
# Save to file
handler.save_to_file("metadata.xml")

Gradual parameter filling

# Add metadata as needed
handler.add_subject("keyword", "CCMM")
handler.add_agent_relationship("Author", "creator", "person")
handler.add_distribution("https://example.com/data", "text/csv")
handler.add_location("Prague", "place")
handler.add_time_reference("2024-01-01", "created")

Loading from file

# Load existing metadata file
handler = CCMMHandler()
if handler.load_from_file("existing_metadata.xml"):
    print("File loaded successfully!")
    print("Title:", handler.get_title())

API Reference

CCMMHandler

Main class for CCMM metadata manipulation.

Constructor

  • __init__(ccmm_path: Optional[str] = None) - Initializes handler with path to CCMM schemas (uses bundled schemas if None)

Required fields

  • set_title(title: str) - Set dataset title
  • set_publication_year(year: int) - Set publication year
  • add_identifier(value: str, scheme: IdentifierScheme, iri: Optional[str] = None) - Add identifier

Optional fields

  • set_version(version: str) - Set version
  • add_description(text: str) - Add description
  • add_alternate_title(title: str, title_type: Optional[str] = None) - Add alternate title
  • add_subject(subject: str, scheme: Optional[str] = None) - Add subject/keyword
  • add_agent_relationship(agent_name: str, role: AgentRole, agent_type: AgentType = AgentType.PERSON) - Add agent relationship
  • add_distribution(access_url: str, format_type: Optional[DistributionFormat] = None) - Add distribution
  • add_location(location: str, location_type: LocationType) - Add location
  • add_time_reference(time_value: str, time_type: TimeReferenceType) - Add time reference

Validation

  • is_valid() -> bool - Check overall validity (includes XSD validation)

Import/Export

  • load_from_file(xml_file_path: str) -> bool - Load from file
  • save_to_file(file_path: str) - Save to file
  • to_xml_string(pretty_print: bool = True) -> str - Convert to XML string

Querying

  • get_title() -> str - Get dataset title
  • get_publication_year() -> int - Get publication year
  • get_identifiers() -> List[Identifier] - Get all identifiers
  • get_subjects() -> List[Subject] - Get all subjects
  • get_summary() -> Dict[str, Any] - Get dataset summary

CCMM Structure

The library supports the following CCMM structure:

  • Dataset (root element)
    • title (required)
    • publication_year (required)
    • identifier (required)
    • version
    • description
    • alternate_title
    • subject
    • qualified_relation (agent relationships)
    • distribution
    • location
    • time_reference
    • and more...

CCMM Schema Integration

This library includes the official CCMM schemas as a git submodule from the CCMM repository. The schemas are automatically bundled with the package and used for validation.

Examples

See examples/example_usage.py for complete usage examples.

Dependencies

  • lxml - for XSD validation
  • xml.etree.ElementTree - for XML manipulation (part of Python standard library)
  • typing - for type hints (part of Python standard library)

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome.


Developed by Roman Dvořák (romandvorak@mlab.cz) at the Institute of Physics of the Czech Academy of Sciences (FZU).

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

pyccmm-1.0.2.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

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

pyccmm-1.0.2-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

File details

Details for the file pyccmm-1.0.2.tar.gz.

File metadata

  • Download URL: pyccmm-1.0.2.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyccmm-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1fe3565efa6648e8e10937e1447dc9e95938e4bc592fb00e8ba6a3104fa9bfaa
MD5 c4609e215fbfce48863c9cb5837d238a
BLAKE2b-256 85724fb1cfb81882d08baafdc7b7e579dc909c77d87a28108202b209c2865571

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyccmm-1.0.2.tar.gz:

Publisher: ci-cd.yml on roman-dvorak/pyCCMM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyccmm-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyccmm-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyccmm-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8c8acfe5d6917fdd5878b2754476277fa82cbe00054dd6679794ff135f20ceee
MD5 d1a0980c26b19e8e48f54c1f31a01ae9
BLAKE2b-256 24f56eef27446d1c7ab4fb997fb66a8a2d76f7a87a4f11da11658bac0746a88b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyccmm-1.0.2-py3-none-any.whl:

Publisher: ci-cd.yml on roman-dvorak/pyCCMM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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