Skip to content

Commit

Permalink
improve editor parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
rettinghaus committed Mar 10, 2023
1 parent aa1b32d commit a935a35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion csv2cmi.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Project]
title = cmi2csv example
editor = Klaus Rettinghaus
editor = Erika Musterfrau <musterfrau@saw-leipzig.de>
publisher = Sächsische Akademie der Wissenschaften zu Leipzig
fileURL = https://raw.githubusercontent.com/saw-leipzig/csv2cmi/master/example/Example.xml
extra-delimiter = ;
Expand Down
13 changes: 8 additions & 5 deletions csv2cmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ def createFileDesc(config):
editors = ['']
editors = config.get('Project', 'editor').splitlines()
for entity in editors:
editor = SubElement(titleStmt, 'editor')
if "@" in entity:
editor.text = parseaddr(entity)[0] + " "
SubElement(editor, 'email').text = parseaddr(entity)[-1]
mailbox = parseaddr(entity)
if "@" in entity and any(mailbox):
editor = SubElement(titleStmt, 'editor')
if mailbox[0]:
editor.text = mailbox[0] + " "
if mailbox[-1]:
SubElement(editor, 'email').text = mailbox[-1]
else:
editor.text = entity
SubElement(titleStmt, 'editor').text = entity
if len(list(titleStmt)) == 1:
logging.warning('Editor missing')
SubElement(titleStmt, 'editor')
Expand Down

0 comments on commit a935a35

Please sign in to comment.