Skip to content

Commit

Permalink
Updated yoda.py to process new metadata scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Frederiks committed Oct 16, 2017
1 parent ff52dff commit ef8dad2
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions moai/yoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def __init__(self, provider):
self.provider = provider
self.id = None
self.modified = None
self.sets = {}
self.deleted = False
self.sets = dict()
self.metadata = dict()

def update(self, path):
Expand All @@ -25,9 +25,9 @@ def update(self, path):

self.root = doc.getroot()

id = xpath.string('//Persistent_Identifier_Datapackage')
id = xpath.string("/metadata/system/Persistent_Identifier_Datapackage[Identifier_Scheme='DOI']/Identifier")
if not id:
log.warning("Missing Persistent Identifier of Datapackage in %s".format(path))
log.warning("Missing Persistent Identifier (DOI) of Datapackage in %s".format(path))
return

self.id = 'oai:%s' % id
Expand Down Expand Up @@ -81,7 +81,7 @@ def update(self, path):
self.metadata['date'] = dates

rightsinxml = [xpath.string('//License'),
xpath.string('//License/Properties/URL')]
xpath.string('//system/License_URL')]

rights = [r for r in rightsinxml if r]
if rights:
Expand All @@ -92,8 +92,8 @@ def update(self, path):
if subject:
self.metadata['subject'] = subject

locations = xpath.strings('//Location_Covered')
perioddates = [xpath.string('//Start_Period'), xpath.string('//End_Period')]
locations = xpath.strings('//Covered_Geolocation_Place')
perioddates = [xpath.string('//Covered_Period/Start_Date'), xpath.string('//Covered_Period/End_Date')]
period = "/".join([d for d in perioddates if d])
if period:
coverage = locations + [period]
Expand All @@ -102,11 +102,3 @@ def update(self, path):
if coverage:
self.metadata['coverage'] = coverage

relations = xpath.strings('//Persistent_Identifier')
if relations:
self.metadata['relation'] = relations

self.sets[u'yoda'] = {
u'name': u'YoDa',
u'description': u'share-collaborate environment for research data'
}

0 comments on commit ef8dad2

Please sign in to comment.