Skip to content

Commit

Permalink
Fix: Only try to map values
Browse files Browse the repository at this point in the history
This is because if the data includes "Null" this gets parsed to None.

Example doi: 10.14280/08241.22
  • Loading branch information
richardhallett committed Apr 20, 2020
1 parent 5cde842 commit 8115d0e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions viringo/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ def nsdc(name):
'rights'
]:
for value in _map.get(name, []):
new_element = etree.SubElement(e_dc, nsdc(name))
# The regular expression here is to filter only valid XML chars
# Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
new_element.text = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '', value)
if value:
new_element = etree.SubElement(e_dc, nsdc(name))
# The regular expression here is to filter only valid XML chars
# Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
new_element.text = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '', value)

def datacite_writer(element: etree.Element, metadata):
"""Writer for writing data in a metadata object out into raw datacite format"""
Expand Down

0 comments on commit 8115d0e

Please sign in to comment.