swh.indexer.metadata_mapping.coarnotify module#

swh.indexer.metadata_mapping.coarnotify.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.indexer.metadata_mapping.coarnotify.validate_mention(notification: dict[str, Any]) bool[source]#

Validate minimal notification’s requirements before indexation.

Parameters:

notification – a compact form of a COAR Notification

Returns:

False if the required props cannot be found in the notification

class swh.indexer.metadata_mapping.coarnotify.CoarNotifyMentionMapping(log_suffix='')[source]#

Bases: BaseExtrinsicMapping

Map & translate a COAR Notify software mention in a CodeMeta format.

COAR Notify mentions are received by swh-coarnotify and saved expanded. Mentions contains metadata on a scientific paper that cites a software.

name = 'coarnotify-mention-codemeta'#
classmethod supported_terms() list[str][source]#
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