swh.indexer.metadata_dictionary.codemeta module#
- class swh.indexer.metadata_dictionary.codemeta.CodemetaMapping(log_suffix='')[source]#
Bases:
SingleFileIntrinsicMappingdedicated 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,
Noneotherwise.
- class swh.indexer.metadata_dictionary.codemeta.SwordCodemetaMapping(log_suffix='')[source]#
Bases:
BaseExtrinsicMappingdedicated 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,
Noneotherwise.
- 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:
SwordCodemetaMappingVariant of
SwordCodemetaMappingthat reads the legacysword-v2-atom-codemeta-v2-in-jsonformat and converts it back tosword-v2-atom-codemeta-v2XML- 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,
Noneotherwise.