swh.indexer.codemeta module

swh.indexer.codemeta.make_absolute_uri(local_name)[source]
swh.indexer.codemeta.compact(doc)[source]

Same as pyld.jsonld.compact, but in the context of CodeMeta.

swh.indexer.codemeta.expand(doc)[source]

Same as pyld.jsonld.expand, but in the context of CodeMeta.

swh.indexer.codemeta.merge_values(v1, v2)[source]

If v1 and v2 are of the form {“@list”: l1} and {“@list”: l2}, returns {“@list”: l1 + l2}. Otherwise, make them lists (if they are not already) and concatenate them.

>>> merge_values('a', 'b')
['a', 'b']
>>> merge_values(['a', 'b'], 'c')
['a', 'b', 'c']
>>> merge_values({'@list': ['a', 'b']}, {'@list': ['c']})
{'@list': ['a', 'b', 'c']}
swh.indexer.codemeta.merge_documents(documents)[source]

Takes a list of metadata dicts, each generated from a different metadata file, and merges them.

Removes duplicates, if any.