Skip to content

Commit 7aa3e2f

Browse files
authored
Merge pull request #53 from saw-leipzig/develop
Version 2.0.1
2 parents 9bf9788 + ef71c15 commit 7aa3e2f

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

.zenodo.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
22
"title": "CSV2CMI",
33
"description": "converts a table of letters into CMI format",
4-
"publication_date": "2019-03-20",
4+
"publication_date": "2019-03-29",
55
"creators": [{
66
"name": "Rettinghaus, Klaus",
77
"orcid": "0000-0003-1898-2543"
88
}],
99
"contributors": [{
10-
"name": "Uwe Kretschmer",
10+
"name": "Kretschmer, Uwe",
11+
"orcid": "0000-0002-3685-6519",
1112
"type": "Other"
1213
},
1314
{
14-
"name": "Jana Dolan",
15+
"name": "Dolan, Jana",
1516
"type": "Other"
1617
}
1718
],

codemeta.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"identifier": "CSV2CMI",
55
"name": "CSV2CMI",
66
"description": "converts a table of letters into CMI format",
7-
"softwareVersion": "2.0.0",
7+
"softwareVersion": "2.0.1",
88
"license": "OSI Approved :: MIT License",
99
"programmingLanguage": "Python :: 3",
1010
"maintainer": "https://orcid.org/0000-0003-1898-2543",
11-
"datePublished": "2019-03-20",
11+
"datePublished": "2019-03-29",
1212
"codeRepository": "https://github.com/saw-leipzig/csv2cmi",
1313
"author": [{
1414
"@id": "https://orcid.org/0000-0003-1898-2543",
@@ -19,15 +19,18 @@
1919
"email": "[email protected]"
2020
}],
2121
"contributor": [{
22+
"@id": "https://orcid.org/0000-0002-3685-6519",
2223
"@type": "Person",
2324
"givenName": "Uwe",
2425
"familyName": "Kretschmer",
26+
"name": "Kretschmer, Uwe",
2527
"email": "[email protected]"
2628
},
2729
{
2830
"@type": "Person",
2931
"givenName": "Jana",
30-
"familyName": "Dolan"
32+
"familyName": "Dolan",
33+
"name": "Dolan, Jana"
3134
}
3235
]
3336
}

csv2cmi.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from xml.etree.ElementTree import Element, SubElement, Comment, ElementTree
1919

2020
__license__ = "MIT"
21-
__version__ = '2.0.0'
21+
__version__ = '2.0.1'
2222

2323
# define log output
2424
logging.basicConfig(format='%(levelname)s: %(message)s')
@@ -159,9 +159,7 @@ def createFileDesc(config):
159159

160160
def createCorrespondent(nameString):
161161
if letter[nameString]:
162-
defaultElement = 'name'
163162
correspondents = []
164-
personIDs = []
165163
# Turning the cells of correspondent names and their IDs into lists since cells
166164
# can contain various correspondents split by an extra delimiter.
167165
# In that case it is essential to be able to call each by their index.
@@ -170,15 +168,15 @@ def createCorrespondent(nameString):
170168
try:
171169
personIDs = letter[nameString + "ID"].split(subdlm)
172170
except KeyError:
173-
defaultElement = 'persName'
171+
personIDs = []
174172
else:
175173
persons = [letter[nameString]]
176174
try:
177175
personIDs = [letter[nameString + "ID"]]
178176
except KeyError:
179-
defaultElement = 'persName'
177+
personIDs = []
180178
for index, person in enumerate(persons):
181-
correspondent = Element(defaultElement)
179+
correspondent = Element('persName')
182180
person = str(person).strip()
183181
# assigning authority file IDs to their correspondents if provided
184182
if (index < len(personIDs)) and personIDs[index]:
@@ -225,7 +223,9 @@ def createCorrespondent(nameString):
225223
except UnicodeEncodeError:
226224
print(authID)
227225
else:
228-
elementset = ('DifferentiatedPerson',
226+
corporatelike = (
227+
'Corporate', 'Company', 'ReligiousAdministrativeUnit')
228+
personlike = ('DifferentiatedPerson',
229229
'Royal', 'Family', 'Legendary')
230230
gndrdf_root = gndrdf.getroot()
231231
latestID = gndrdf_root[0].get(
@@ -235,12 +235,12 @@ def createCorrespondent(nameString):
235235
'%s returns new ID %s', authID, latestID)
236236
rdftype = gndrdf_root.find(
237237
'.//rdf:type', ns).get('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}resource')
238-
if 'Corporate' in rdftype:
238+
if any(entity in rdftype for entity in corporatelike):
239239
correspondent = Element('orgName')
240-
elif any(entity in rdftype for entity in elementset):
240+
elif any(entity in rdftype for entity in personlike):
241241
correspondent = Element('persName')
242242
else:
243-
correspondent = Element('name')
243+
authID = ''
244244
if 'UndifferentiatedPerson' in rdftype:
245245
logging.warning(
246246
'%sID in line %s links to undifferentiated Person', nameString, table.line_num)
@@ -268,7 +268,7 @@ def createCorrespondent(nameString):
268268
else:
269269
logging.error(
270270
'No proper authority record in line %s for %s', table.line_num, nameString)
271-
if authID and correspondent.tag != "name":
271+
if authID:
272272
correspondent.set('ref', authID)
273273
else:
274274
logging.debug('ID for "%s" missing in line %s',

0 commit comments

Comments
 (0)