swh.indexer.metadata_mapping.sword module#
- class swh.indexer.metadata_mapping.sword.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.
- class swh.indexer.metadata_mapping.sword.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.