Coverage for src/oc_graphenricher/_identifiers.py: 100%
15 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-07-06 11:55 +0000
« prev ^ index » next coverage.py v7.14.3, created at 2026-07-06 11:55 +0000
1# SPDX-FileCopyrightText: 2026 Arcangelo Massari <arcangelo.massari@unibo.it>
2#
3# SPDX-License-Identifier: ISC
5from __future__ import annotations
7from typing import TYPE_CHECKING
9from oc_ocdm.graph.graph_entity import GraphEntity
11if TYPE_CHECKING:
12 from collections.abc import Iterator
14 from oc_ocdm.graph.entities.bibliographic_entity import BibliographicEntity
17BR_API_SCHEMAS = {
18 GraphEntity.iri_doi: "doi",
19 GraphEntity.iri_issn: "issn",
20 GraphEntity.iri_pmid: "pmid",
21 GraphEntity.iri_pmcid: "pmcid",
22}
25def valid_identifiers(entity: BibliographicEntity) -> Iterator[tuple[str, str]]:
26 for identifier in entity.get_identifiers():
27 scheme = identifier.get_scheme()
28 literal = identifier.get_literal_value()
29 if scheme is not None and literal is not None:
30 yield scheme, literal
33def supported_br_identifiers(entity: BibliographicEntity) -> Iterator[tuple[str, str]]:
34 for scheme, literal in valid_identifiers(entity):
35 schema = BR_API_SCHEMAS.get(scheme)
36 if schema is not None:
37 yield schema, literal