Skip to content

Commit

Permalink
Merge 71b31c8 into 60fca5e
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorrell committed May 5, 2020
2 parents 60fca5e + 71b31c8 commit a075e9a
Show file tree
Hide file tree
Showing 27 changed files with 1,945 additions and 1,484 deletions.
12 changes: 9 additions & 3 deletions .travis.yml
Expand Up @@ -19,9 +19,14 @@ cache:
- $HOME/.cache/pip

python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"
- "3.8"

matrix:
allow_failures:
- python: 3.7
- python: 3.8

env:
- REQUIREMENTS=lowest
Expand Down Expand Up @@ -49,7 +54,8 @@ deploy:
password:
secure: "iFwYlgl8UsWnh+oxvl4pmW9eBB3JrLC0hyPDfurxZIUaAHolTazbWhEPLmp4rh6WF3WlfVzCIgQJ+VX2up3kJk6i/JJE2RyhTYCMwLb8jtJWhH0KUoaD1LqP0kpos6keyuyG1Y3n5OxVYWXObVsVgo0i0IAw4xp+/YFFQImK4dc="
distributions: "sdist bdist_wheel"
skip_existing: true
on:
tags: true
python: "2.7"
python: "3.6"
condition: $REQUIREMENTS = release
14 changes: 14 additions & 0 deletions CHANGES.rst
@@ -1,5 +1,19 @@
Changes
=======
Version v1.1.0 (TBD):

- Adds full support for DataCite Metadata Schema v4.2 XML generation.
- Uses Official DataCite JSON Schema, which has the following notable changes
from the previous schema:

- Uses "identifiers" which is a combination of the XML "identifier" and
"alternativeIdentifiers" elements
- "creatorName" is now "name"
- "contributorName" is now "name"
- "affiliations" is now "affiliation" (is still an array)
- There is no longer a funder identifier object (the identifier and type are just
elements)

Version v1.0.1 (released 2018-03-08):

- Fixes schema location url for DataCite v4.1
Expand Down
52 changes: 30 additions & 22 deletions datacite/schema42.py
Expand Up @@ -56,13 +56,36 @@ def validate(data):
return validator.is_valid(data)


@rules.rule('identifier')
def identifier(path, value):
"""Transform identifier."""
return E.identifier(
value['identifier'],
identifierType=value['identifierType']
)
@rules.rule('identifiers')
def identifiers(root, values):
"""Transform identifiers to alternateIdenftifiers and identifier."""
"""
We assume there will only be 1 DOI identifier for the record.
Any other identifiers are alternative identifiers.
"""
root = ''
doi = ''
for value in values:
if value['identifierType'] == 'DOI':
if doi != '':
#Don't know what to do with two DOIs
#Which is the actual identifier?
raise TypeError
doi = E.identifier(
value['identifier'],
identifierType='DOI'
)
else:
if root == '':
root = E.alternateIdentifiers()
elem = E.alternateIdentifier(value['identifier'])
elem.set('alternateIdentifierType', value['identifierType'])
root.append(elem)
if root == '':
#If we only have the DOI
return doi
else:
return (root,doi)


def affiliations(root, values):
Expand Down Expand Up @@ -231,21 +254,6 @@ def resource_type(path, value):
return elem


@rules.rule('alternateIdentifiers')
def alternate_identifiers(path, values):
"""Transform alternateIdenftifiers."""
if not values:
return

root = E.alternateIdentifiers()
for value in values:
elem = E.alternateIdentifier(value['alternateIdentifier'])
elem.set('alternateIdentifierType', value['alternateIdentifierType'])
root.append(elem)

return root


@rules.rule('relatedIdentifiers')
def related_identifiers(path, values):
"""Transform relatedIdentifiers."""
Expand Down

0 comments on commit a075e9a

Please sign in to comment.