swh.indexer.citation package#

Submodules:

Module contents:

class swh.indexer.citation.CitationFormat(value)[source]#

Bases: Enum

BIBTEX = 'BibTeX'#
CSL = 'CSL JSON'#
swh.indexer.citation.codemeta_to_citation(doc: Dict[str, Any], format: CitationFormat, swhid: QualifiedSWHID | None = None, force_codemeta_context: bool = False, resolve_unknown_context_url: bool = False) str[source]#

Generate a citation from a parsed codemeta.json file.

Parameters:
  • doc – parsed codemeta.json file

  • format – citation format to generate

  • swhid – optional SWHID to embed in the citation

  • force_codemeta_context – if True, the @context field 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

  • resolve_unknown_context_url – if const:True unknown JSON-LD context URL will be fetched using requests instead of raising an exception, False by default as it can lead sending requests to arbitrary URLs so use with caution

Returns:

A citation string in the requested format.

Raises:

CitationError – when citation could not be generated