Skip to content
Snippets Groups Projects
Commit 13e9bf18 authored by vlorentz's avatar vlorentz
Browse files

sword mapping: Add support for Atom author elements

Atom documents from old deposits usually use these instead of codemeta's
parent 90dad275
No related branches found
No related tags found
1 merge request!472sword mapping: Add support for Atom author elements
......@@ -67,9 +67,13 @@ class SwordCodemetaMapping(BaseExtrinsicMapping):
namespace = m.group("namespace")
localname = m.group("localname")
if namespace == ATOM_URI and localname in ("title", "name"):
# Convert Atom name/title to Codemeta name; in case codemeta:name
# Convert Atom to Codemeta name; in case codemeta:name
# is not provided or different
doc["name"].append(self.xml_to_jsonld(child))
elif namespace == ATOM_URI and localname in ("author", "email"):
# ditto for these author properties (note that author email is also
# covered by the previous test)
doc[localname].append(self.xml_to_jsonld(child))
elif namespace in _IGNORED_NAMESPACES:
# SWORD-specific namespace that is not interesting to translate
pass
......
......@@ -213,6 +213,10 @@ def test_sword_basics():
<codemeta:author>
<codemeta:name>Author 2</codemeta:name>
</codemeta:author>
<author>
<name>Author 3</name>
<email>bar@example.org</email>
</author>
</entry>
"""
......@@ -223,6 +227,7 @@ def test_sword_basics():
"author": [
{"name": "Author 1", "email": "foo@example.org"},
{"name": "Author 2"},
{"name": "Author 3", "email": "bar@example.org"},
],
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment