Skip to content

Commit

Permalink
Merge pull request #53 from saw-leipzig/develop
Browse files Browse the repository at this point in the history
Version 2.0.1
  • Loading branch information
rettinghaus authored Mar 29, 2019
2 parents 9bf9788 + ef71c15 commit 7aa3e2f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
7 changes: 4 additions & 3 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"title": "CSV2CMI",
"description": "converts a table of letters into CMI format",
"publication_date": "2019-03-20",
"publication_date": "2019-03-29",
"creators": [{
"name": "Rettinghaus, Klaus",
"orcid": "0000-0003-1898-2543"
}],
"contributors": [{
"name": "Uwe Kretschmer",
"name": "Kretschmer, Uwe",
"orcid": "0000-0002-3685-6519",
"type": "Other"
},
{
"name": "Jana Dolan",
"name": "Dolan, Jana",
"type": "Other"
}
],
Expand Down
9 changes: 6 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"identifier": "CSV2CMI",
"name": "CSV2CMI",
"description": "converts a table of letters into CMI format",
"softwareVersion": "2.0.0",
"softwareVersion": "2.0.1",
"license": "OSI Approved :: MIT License",
"programmingLanguage": "Python :: 3",
"maintainer": "https://orcid.org/0000-0003-1898-2543",
"datePublished": "2019-03-20",
"datePublished": "2019-03-29",
"codeRepository": "https://github.com/saw-leipzig/csv2cmi",
"author": [{
"@id": "https://orcid.org/0000-0003-1898-2543",
Expand All @@ -19,15 +19,18 @@
"email": "[email protected]"
}],
"contributor": [{
"@id": "https://orcid.org/0000-0002-3685-6519",
"@type": "Person",
"givenName": "Uwe",
"familyName": "Kretschmer",
"name": "Kretschmer, Uwe",
"email": "[email protected]"
},
{
"@type": "Person",
"givenName": "Jana",
"familyName": "Dolan"
"familyName": "Dolan",
"name": "Dolan, Jana"
}
]
}
22 changes: 11 additions & 11 deletions csv2cmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from xml.etree.ElementTree import Element, SubElement, Comment, ElementTree

__license__ = "MIT"
__version__ = '2.0.0'
__version__ = '2.0.1'

# define log output
logging.basicConfig(format='%(levelname)s: %(message)s')
Expand Down Expand Up @@ -159,9 +159,7 @@ 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.
Expand All @@ -170,15 +168,15 @@ def createCorrespondent(nameString):
try:
personIDs = letter[nameString + "ID"].split(subdlm)
except KeyError:
defaultElement = 'persName'
personIDs = []
else:
persons = [letter[nameString]]
try:
personIDs = [letter[nameString + "ID"]]
except KeyError:
defaultElement = 'persName'
personIDs = []
for index, person in enumerate(persons):
correspondent = Element(defaultElement)
correspondent = Element('persName')
person = str(person).strip()
# assigning authority file IDs to their correspondents if provided
if (index < len(personIDs)) and personIDs[index]:
Expand Down Expand Up @@ -225,7 +223,9 @@ def createCorrespondent(nameString):
except UnicodeEncodeError:
print(authID)
else:
elementset = ('DifferentiatedPerson',
corporatelike = (
'Corporate', 'Company', 'ReligiousAdministrativeUnit')
personlike = ('DifferentiatedPerson',
'Royal', 'Family', 'Legendary')
gndrdf_root = gndrdf.getroot()
latestID = gndrdf_root[0].get(
Expand All @@ -235,12 +235,12 @@ def createCorrespondent(nameString):
'%s returns new ID %s', authID, latestID)
rdftype = gndrdf_root.find(
'.//rdf:type', ns).get('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}resource')
if 'Corporate' in rdftype:
if any(entity in rdftype for entity in corporatelike):
correspondent = Element('orgName')
elif any(entity in rdftype for entity in elementset):
elif any(entity in rdftype for entity in personlike):
correspondent = Element('persName')
else:
correspondent = Element('name')
authID = ''
if 'UndifferentiatedPerson' in rdftype:
logging.warning(
'%sID in line %s links to undifferentiated Person', nameString, table.line_num)
Expand Down Expand Up @@ -268,7 +268,7 @@ def createCorrespondent(nameString):
else:
logging.error(
'No proper authority record in line %s for %s', table.line_num, nameString)
if authID and correspondent.tag != "name":
if authID:
correspondent.set('ref', authID)
else:
logging.debug('ID for "%s" missing in line %s',
Expand Down

0 comments on commit 7aa3e2f

Please sign in to comment.