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 titleset_publication_year(year: int)- Set publication yearadd_identifier(value: str, scheme: IdentifierScheme, iri: Optional[str] = None)- Add identifier
Optional fields
set_version(version: str)- Set versionadd_description(text: str)- Add descriptionadd_alternate_title(title: str, title_type: Optional[str] = None)- Add alternate titleadd_subject(subject: str, scheme: Optional[str] = None)- Add subject/keywordadd_agent_relationship(agent_name: str, role: AgentRole, agent_type: AgentType = AgentType.PERSON)- Add agent relationshipadd_distribution(access_url: str, format_type: Optional[DistributionFormat] = None)- Add distributionadd_location(location: str, location_type: LocationType)- Add locationadd_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 filesave_to_file(file_path: str)- Save to fileto_xml_string(pretty_print: bool = True) -> str- Convert to XML string
Querying
get_title() -> str- Get dataset titleget_publication_year() -> int- Get publication yearget_identifiers() -> List[Identifier]- Get all identifiersget_subjects() -> List[Subject]- Get all subjectsget_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 validationxml.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fe3565efa6648e8e10937e1447dc9e95938e4bc592fb00e8ba6a3104fa9bfaa
|
|
| MD5 |
c4609e215fbfce48863c9cb5837d238a
|
|
| BLAKE2b-256 |
85724fb1cfb81882d08baafdc7b7e579dc909c77d87a28108202b209c2865571
|
Provenance
The following attestation bundles were made for pyccmm-1.0.2.tar.gz:
Publisher:
ci-cd.yml on roman-dvorak/pyCCMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyccmm-1.0.2.tar.gz -
Subject digest:
1fe3565efa6648e8e10937e1447dc9e95938e4bc592fb00e8ba6a3104fa9bfaa - Sigstore transparency entry: 268806566
- Sigstore integration time:
-
Permalink:
roman-dvorak/pyCCMM@0f83ee11d60ec19eeca64fecc5e06462015b85d7 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/roman-dvorak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@0f83ee11d60ec19eeca64fecc5e06462015b85d7 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c8acfe5d6917fdd5878b2754476277fa82cbe00054dd6679794ff135f20ceee
|
|
| MD5 |
d1a0980c26b19e8e48f54c1f31a01ae9
|
|
| BLAKE2b-256 |
24f56eef27446d1c7ab4fb997fb66a8a2d76f7a87a4f11da11658bac0746a88b
|
Provenance
The following attestation bundles were made for pyccmm-1.0.2-py3-none-any.whl:
Publisher:
ci-cd.yml on roman-dvorak/pyCCMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyccmm-1.0.2-py3-none-any.whl -
Subject digest:
8c8acfe5d6917fdd5878b2754476277fa82cbe00054dd6679794ff135f20ceee - Sigstore transparency entry: 268806572
- Sigstore integration time:
-
Permalink:
roman-dvorak/pyCCMM@0f83ee11d60ec19eeca64fecc5e06462015b85d7 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/roman-dvorak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@0f83ee11d60ec19eeca64fecc5e06462015b85d7 -
Trigger Event:
release
-
Statement type: