qubes.bulk_import

Bulk-import publication metadata from QUBES Hub via the OAI-PMH API.

QUBES Hub exposes an OAI-PMH (Open Archives Initiative Protocol for Metadata Harvesting) endpoint. This module reads from the locally cached qubes_records.json file (generated by convert_qubes_xml_to_json.py) and translates each record into a standardised OME EducationResource card.

Attributes

QUBES_OAI_URL

QUBES_BASE_URL

logger

plugin

here

Functions

_parse_records(...)

Validate raw record dicts into ModelItem objects.

bulk_translate(...)

Translate raw QUBES record dicts to OME EducationResource cards.

bulk_import(→ list[dict])

Load QUBES records from the local cache and return serialised OME records.

Module Contents

qubes.bulk_import.QUBES_OAI_URL = 'https://qubeshub.org/oaipmh/?verb=ListRecords&metadataPrefix=oai_dc&set=publications'
qubes.bulk_import.QUBES_BASE_URL = 'https://qubeshub.org'
qubes.bulk_import.logger
qubes.bulk_import.plugin
qubes.bulk_import._parse_records(items: list) list[server.plugins.qubes.qubes_models.ModelItem]

Validate raw record dicts into ModelItem objects.

Uses a Python 3.13+ ExceptionGroup to collect all validation errors and report them together while returning valid records to the caller.

qubes.bulk_import.bulk_translate(records: list[dict]) collections.abc.Iterator[server.plugins.ome_plugin.EducationResource]

Translate raw QUBES record dicts to OME EducationResource cards.

qubes.bulk_import.bulk_import(cache_path: pathlib.Path | None = None) list[dict]

Load QUBES records from the local cache and return serialised OME records.

The cache file qubes_records.json is generated by convert_qubes_xml_to_json.py from the OAI-PMH XML export. Run that script first if the cache does not yet exist.

Args:
cache_path: Path to qubes_records.json. If None, defaults

to the file next to this module.

Returns:

A list of serialised EducationResource dicts.

Raises:

FileNotFoundError: If qubes_records.json does not exist.

qubes.bulk_import.here