swh.indexer.metadata_dictionary.codemeta module#
- class swh.indexer.metadata_dictionary.codemeta.CodemetaMapping(log_suffix='')[source]#
Bases:
SingleFileIntrinsicMapping
dedicated class for CodeMeta (codemeta.json) mapping and translation
- name = 'codemeta'#
- string_fields = None#
- translate(content: bytes) Dict[str, Any] | None [source]#
Translates content by parsing content from a bytestring containing mapping-specific data and translating with the appropriate mapping to JSON-LD using the Codemeta and ForgeFed vocabularies.
- Parameters:
raw_content – raw content to translate
- Returns:
translated metadata in JSON friendly form needed for the content if parseable,
None
otherwise.
- class swh.indexer.metadata_dictionary.codemeta.SwordCodemetaMapping(log_suffix='')[source]#
Bases:
BaseExtrinsicMapping
dedicated class for mapping and translation from JSON-LD statements embedded in SWORD documents, optionally using Codemeta contexts, as described in the Protocol reference.
- name = 'sword-codemeta'#
- classmethod extrinsic_metadata_formats() Tuple[str, ...] [source]#
Returns the list of extrinsic metadata formats which can be translated by this mapping
- translate(content: bytes) Dict[str, Any] | None [source]#
Translates content by parsing content from a bytestring containing mapping-specific data and translating with the appropriate mapping to JSON-LD using the Codemeta and ForgeFed vocabularies.
- Parameters:
raw_content – raw content to translate
- Returns:
translated metadata in JSON friendly form needed for the content if parseable,
None
otherwise.
- swh.indexer.metadata_dictionary.codemeta.iter_keys(d)[source]#
Recursively iterates on dictionary keys
- class swh.indexer.metadata_dictionary.codemeta.JsonSwordCodemetaMapping(log_suffix='')[source]#
Bases:
SwordCodemetaMapping
Variant of
SwordCodemetaMapping
that reads the legacysword-v2-atom-codemeta-v2-in-json
format and converts it back tosword-v2-atom-codemeta-v2
XML- name = 'json-sword-codemeta'#
- classmethod extrinsic_metadata_formats() Tuple[str, ...] [source]#
Returns the list of extrinsic metadata formats which can be translated by this mapping
- translate(content: bytes) Dict[str, Any] | None [source]#
Translates content by parsing content from a bytestring containing mapping-specific data and translating with the appropriate mapping to JSON-LD using the Codemeta and ForgeFed vocabularies.
- Parameters:
raw_content – raw content to translate
- Returns:
translated metadata in JSON friendly form needed for the content if parseable,
None
otherwise.