API reference
Generated from the source with mkdocstrings.
Parsers
bibliofabric.codemeta.parse.parse_codemeta(source: Mapping[str, Any] | str | bytes) -> CodemetaRecord
Parse a codemeta.json document from a mapping or JSON text.
A document that is not a single JSON-LD node raises
:class:bibliofabric.ValidationError; the flat @graph form is not
supported, and a structured @context object raises too, while an
@context array is accepted when one string entry names CodeMeta.
Unknown terms raise too, so a document that carries a key
outside the CodeMeta vocabulary fails instead of parsing.
bibliofabric.codemeta.parse.parse_codemeta_file(path: Path | str) -> CodemetaRecord
Read and parse a codemeta.json file.
bibliofabric.codemeta.parse.parse_cff(source: Mapping[str, Any] | str | bytes) -> CffRecord
Parse a CITATION.cff document from a mapping or YAML text.
The file is validated against the published 1.2.0 schema shape, so
keys the format does not define raise, while files that declare an
older cff-version still parse when their keys fit.
bibliofabric.codemeta.parse.parse_cff_file(path: Path | str) -> CffRecord
Read and parse a CITATION.cff file.
All four are re-exported from bibliofabric.codemeta. Every failure raises
bibliofabric.ValidationError, which carries the raw document in raw.
There is no client class: the parsers read local files and text only, and no HTTP base URL exists.
CodeMeta models
bibliofabric.codemeta.CodemetaRecord
A parsed codemeta.json document.
Unknown keys raise ValidationError, so a document with a term the
CodeMeta vocabulary does not define is rejected instead of parsed. The
field list covers the terms of the published CodeMeta 2.0, 3.0, and 4.0
contexts; a term two contexts spell differently reads from either
spelling, so legacy files parse like current ones.
bibliofabric.codemeta.CodemetaAgent
A Person, Organization, ContactPoint, or Role of a record.
The model carries the schema.org properties the vocabulary points at for
Person and Organization; other schema.org keys stay in model_extra.
bibliofabric.codemeta.CodemetaCreativeWork
A schema.org CreativeWork an agent reference points at.
Grants, encodings, and related works land here; their schema.org keys
that the CodeMeta vocabulary does not name stay in model_extra.
CodemetaRecord uses extra="forbid", so a key outside the CodeMeta
vocabulary raises; CodemetaAgent and CodemetaCreativeWork use
extra="allow" because their properties come from schema.org. The term
constants RECORD_TYPES and AGENT_TYPES list the accepted @type
values.
CFF models
bibliofabric.codemeta.CffRecord
A parsed CITATION.cff document.
The field list and the required keys follow the 1.2.0 schema
(cff-version, title, message, authors); unknown keys are
rejected, so a file with top-level keys the format does not define, such
as a stray journal, fails with the offending key in the message.
bibliofabric.codemeta.CffReference
One entry of references or preferred-citation.
The entity fields accept the plain strings older CFF 1.0 files write where the 1.2.0 schema wants an entity object.
bibliofabric.codemeta.CffPerson
A person in CFF form: given-names/family-names and contact keys.
bibliofabric.codemeta.CffEntity
An organization author or contact in CFF form, keyed by name.
bibliofabric.codemeta.CffIdentifier
One identifier of a work: doi, url, or swh.
The CFF models follow the 1.2.0 schema: extra="forbid" everywhere, and
CffRecord requires cff-version, title, message, and authors.
CffActor is the CffPerson | CffEntity union the author, contact, and
editor lists carry.