Skip to content

Commit

Permalink
Merge pull request #52 from saw-leipzig/develop
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
rettinghaus authored Mar 29, 2019
2 parents 24c7191 + 2f65309 commit 9bf9788
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions csv2cmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,31 @@ def createFileDesc(config):

def createCorrespondent(nameString):
if letter[nameString]:
defaultElement = 'name'
correspondents = []
personIDs = []
# Turning the cells of correspondent names and their IDs into lists since cells
# can contain various correspondents split by an extra delimiter.
# In that case it is essential to be able to call each by their index.
if subdlm:
persons = letter[nameString].split(subdlm)
personIDs = letter[nameString + "ID"].split(subdlm)
try:
personIDs = letter[nameString + "ID"].split(subdlm)
except KeyError:
defaultElement = 'persName'
else:
persons = [letter[nameString].strip()]
personIDs = [letter[nameString + "ID"]]
persons = [letter[nameString]]
try:
personIDs = [letter[nameString + "ID"]]
except KeyError:
defaultElement = 'persName'
for index, person in enumerate(persons):
correspondent = Element(defaultElement)
person = str(person).strip()
correspondent = Element('name')
# assigning authority file IDs to their correspondents if provided
if (index < len(personIDs)) and personIDs[index]:
# by default complete GND-IDNs to full URI
if 'http://' not in str(personIDs[index].strip()) and str(personIDs[index])[:-2].isdigit():
if 'http://' not in str(personIDs[index].strip()) and str(personIDs[index].strip())[:-2].isdigit():
logging.debug('Assigning ID %s to GND', str(
personIDs[index].strip()))
authID = 'http://d-nb.info/gnd/' + \
Expand Down Expand Up @@ -563,7 +571,8 @@ def processPlace(letter, correspondent):
bibl.text = editionTitle
bibl.set('type', editionType)
except configparser.NoOptionError:
logging.warning('Incomplete section %s in ini file. Title and type option must be set.', editionKey)
logging.warning(
'Incomplete section %s in ini file. Title and type option must be set.', editionKey)
except configparser.NoSectionError:
# if there is no matching section, we assume that there should be no one
pass
Expand Down

0 comments on commit 9bf9788

Please sign in to comment.