Commit fc6653fb authored by Merlijn Wajer's avatar Merlijn Wajer
Browse files

metadata: more fixes for weird XML

Relates to commit 13bf6707

except that this time the problem occured with XML looking like this:

    <subject>and index</subject>
    <subject>ve thinking</subject>
    <subject>innovations</subject>
    <subject>in educ</subject>
    <subject/>

And it was turned into this:

    >>> m=parse_item_metadata('/tmp/alda0000unse_meta.xml')
    >>> m['subject']
    ['and index', 've thinking', 'innovations', 'in educ', None]
parent 865776f1
......@@ -16,14 +16,14 @@ def parse_item_metadata(path):
md = {}
for elem in root:
if elem.text is None:
continue
if elem.tag in md:
if isinstance(md[elem.tag], list):
md[elem.tag].append(elem.text)
else:
md[elem.tag] = [md[elem.tag], elem.text]
else:
if elem.text is None:
continue
md[elem.tag] = elem.text
return md
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment