swh.indexer.bibtex module#
- swh.indexer.bibtex.TMP_ROOT_URI_PREFIX = 'https://www.softwareheritage.org/schema/2022/indexer/tmp-node/'#
IRI used for skolemization; it is not used outside
codemeta_to_bibtex().
- swh.indexer.bibtex.codemeta_to_bibtex(doc: Dict[str, Any], swhid: QualifiedSWHID | None = None, *, resolve_unknown_context_url: bool = False, force_codemeta_context: bool = False) str[source]#
Generate citation in BibTeX format from a parsed
codemeta.jsonfile.- Parameters:
doc – parsed
codemeta.jsonfileswhid – optional SWHID to add as
swhidfield in BibTeX citationresolve_unknown_context_url – if const:True unknown JSON-LD context URL will be fetched using
requestsinstead of raising an exception,Falseby default as it can lead sending requests to arbitrary URLs so use with cautionforce_codemeta_context – if
True, the@contextfield in the JSON-LD document will be set to the CodeMeta v3.0 one, this can be used to ensure citation can be generated when strict JSON-LD parsing failed
- Returns:
A BibTeX citation as a string.
- Raises:
BibTeXCitationError – when citation could not be generated
- swh.indexer.bibtex.cff_to_bibtex(content: str, swhid: QualifiedSWHID | None = None) str[source]#
Generate citation in BibTeX format from a raw
citation.cfffile.- Parameters:
content – raw content of a
citation.cfffileswhid – optional SWHID to add as
swhidfield in BibTeX citation
- Returns:
A BibTeX citation as a string.
- Raises:
BibTeXCitationError – when citation could not be generated