Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Publisher is a contributor role
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Sep 19, 2017
1 parent 915aaad commit 8f7fa61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 11 additions & 5 deletions datapackage_pipelines_ukds/processors/add_oai_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,28 @@ def _make_title_from_identifier(identifier):
return title


contributors = []

if 'title' in record:
datapackage['title'] = record['title'][0]

if 'description' in record:
datapackage['description'] = record['description'][0]

if 'creator' in record:
datapackage['contributors'] = \
[{'title': c, 'role': 'author'} for c in record['creator']]
contributors += [{'title': c, 'role': 'author'}
for c in record['creator']]

if 'publisher' in record:
contributors += [{'title': c, 'role': 'publisher'}
for c in record['publisher']]

if 'relation' in record:
datapackage['homepage'] = record['relation'][0]

if 'subject' in record:
datapackage['keywords'] = [kw for kw in record['subject']]

if 'publisher' in record:
datapackage['publisher'] = record['publisher'][0]

if 'identifier' in record:
'''Discover sources from the OAI record. UKDS creates a erroneous last
record, which is excluded here by looking for the string 'error in
Expand All @@ -61,5 +64,8 @@ def _make_title_from_identifier(identifier):
[{'title': _make_title_from_identifier(ider), 'path': ider}
for ider in record['identifier'] if 'error in script' not in ider]

if contributors:
datapackage['contributors'] = contributors


spew(datapackage, res_iter)
6 changes: 4 additions & 2 deletions tests/test_add_oai_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ def test_add_oai_metadata_processor(self):
'resources': [],
'title': 'Farm Management Survey- SPSS data set',
'description': 'A description of the data set...',
'contributors': [{'title': 'Winter, Michael', 'role': 'author'}],
'contributors': [
{'title': 'Winter, Michael', 'role': 'author'},
{'title': 'UK Data Archive', 'role': 'publisher'}
],
'homepage': 'http://reshare.ukdataservice.ac.uk/851500/',
'keywords': ['Environment, conservation and land use', 'History', 'Economics', 'Industry and management'], # noqa
'publisher': 'UK Data Archive',
'sources': [{'title': 'RES-062-23-1831 SPSS data handbook.xlsx', 'path': 'http://reshare.ukdataservice.ac.uk/851500/1/RES-062-23-1831%20SPSS%20data%20handbook.xlsx'}, {'title': 'RES-062-23-1831 FBS data for ESRC archive.sav', 'path': 'http://reshare.ukdataservice.ac.uk/851500/2/RES-062-23-1831%20FBS%20data%20for%20ESRC%20archive.sav'}, {'title': 'http://reshare.ukdataservice.ac.uk/851500/3/nofile/', 'path': 'http://reshare.ukdataservice.ac.uk/851500/3/nofile/'}, {'title': 'unknown://notapath', 'path': 'unknown://notapath'}] # noqa
}
self.assertEqual(spew_dp, expected_dp)

0 comments on commit 8f7fa61

Please sign in to comment.