swh.coarnotify.indexer module#
Metadata mappings for swh-indexer.
- swh.coarnotify.indexer.load_and_compact_notification(content: bytes | str) dict[str, Any] | None[source]#
Load and compact a notification from the REMS.
Errors logs will be written if something went wrong in the process.
- Parameters:
content – the expanded COAR Notification
- Returns:
The compacted form of the COAR Notification or None if we weren’t able to read it
- swh.coarnotify.indexer.validate_mention(notification: dict[str, Any]) URIRef[source]#
Validate minimal notification’s requirements before indexation.
FIXME: CN specs (1.0.1) are a bit unclear about what should context_data contains, especially the id. It would be more logical to find the paper URI in the id and then some metadata about it, but instead we might find the software URI in the id and then metadata about the paper. We are trying to make some changes on the specs but meanwhile we’ll skip verifying that context.id == object.as:subject
- Parameters:
notification – a compact form of a COAR Notification
- Raises:
CoarNotifyValidationError – something is wrong with the notification payload
- Returns:
The relationship type
- class swh.coarnotify.indexer.CoarNotifyMentionMapping(log_suffix='')[source]#
Bases:
BaseExtrinsicMappingMap & translate a COAR Notify software mention in a CodeMeta format.
COAR Notify mentions are received by
swh-coarnotifyand saved expanded. Mentions contains metadata on a scientific paper that cites a software.- name = 'coarnotify-mention-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]#
Parse JSON and compact the payload to access the mention.
The whole context of the AnnounceRelationship notification will be indexed as it contains metadata about the scientific paper citing the software.
TODO: At some point we might need to fetch metadata from the paper URL as COAR Notifications are not made to contain all the metadata but to indicate where we should find them.
TODO: We will need to handle cancellations of a mention if it was made by mistake. Maybe we could use the original notification id and an empty context to overwrite the previous citation when merging documents ? It is with this in mind that the notification ID is added to the citation.
- Parameters:
content – the raw expanded COAR Notification
- Returns:
A CodeMeta citation if the notification was valid or None