@@ -159,23 +159,31 @@ def createFileDesc(config):
159
159
160
160
def createCorrespondent (nameString ):
161
161
if letter [nameString ]:
162
+ defaultElement = 'name'
162
163
correspondents = []
164
+ personIDs = []
163
165
# Turning the cells of correspondent names and their IDs into lists since cells
164
166
# can contain various correspondents split by an extra delimiter.
165
167
# In that case it is essential to be able to call each by their index.
166
168
if subdlm :
167
169
persons = letter [nameString ].split (subdlm )
168
- personIDs = letter [nameString + "ID" ].split (subdlm )
170
+ try :
171
+ personIDs = letter [nameString + "ID" ].split (subdlm )
172
+ except KeyError :
173
+ defaultElement = 'persName'
169
174
else :
170
- persons = [letter [nameString ].strip ()]
171
- personIDs = [letter [nameString + "ID" ]]
175
+ persons = [letter [nameString ]]
176
+ try :
177
+ personIDs = [letter [nameString + "ID" ]]
178
+ except KeyError :
179
+ defaultElement = 'persName'
172
180
for index , person in enumerate (persons ):
181
+ correspondent = Element (defaultElement )
173
182
person = str (person ).strip ()
174
- correspondent = Element ('name' )
175
183
# assigning authority file IDs to their correspondents if provided
176
184
if (index < len (personIDs )) and personIDs [index ]:
177
185
# by default complete GND-IDNs to full URI
178
- if 'http://' not in str (personIDs [index ].strip ()) and str (personIDs [index ])[:- 2 ].isdigit ():
186
+ if 'http://' not in str (personIDs [index ].strip ()) and str (personIDs [index ]. strip () )[:- 2 ].isdigit ():
179
187
logging .debug ('Assigning ID %s to GND' , str (
180
188
personIDs [index ].strip ()))
181
189
authID = 'http://d-nb.info/gnd/' + \
@@ -563,7 +571,8 @@ def processPlace(letter, correspondent):
563
571
bibl .text = editionTitle
564
572
bibl .set ('type' , editionType )
565
573
except configparser .NoOptionError :
566
- logging .warning ('Incomplete section %s in ini file. Title and type option must be set.' , editionKey )
574
+ logging .warning (
575
+ 'Incomplete section %s in ini file. Title and type option must be set.' , editionKey )
567
576
except configparser .NoSectionError :
568
577
# if there is no matching section, we assume that there should be no one
569
578
pass
0 commit comments