Skip to content

Commit b23c8fd

Browse files
Merge pull request #37 from rafaelpezzuto/change-editor-to-creator-and-fix-dockerfile
Altera editor para campo creator e melhora Dockerfile
2 parents d57a3f3 + f3386a5 commit b23c8fd

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

Dockerfile

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
FROM python:2.7.14-jessie
2-
ENV PYTHONUNBUFFERED 1
1+
FROM python:2.7.14-jessie AS build
32

4-
# Build-time metadata as defined at http://label-schema.org
5-
ARG BUILD_DATE
6-
ARG VCS_REF
7-
ARG WEBAPP_VERSION
3+
COPY . /src
84

9-
ENV IMAGE_BUILD_DATE ${BUILD_DATE}
10-
ENV IMAGE_VCS_REF ${VCS_REF}
11-
ENV IMAGE_WEBAPP_VERSION ${WEBAPP_VERSION}
5+
RUN pip install --upgrade pip && pip install wheel
6+
RUN cd /src && python setup.py bdist_wheel -d /deps
127

13-
COPY requirements.txt production.ini /app/
14-
COPY dist /tmp/pypa/
158

16-
RUN apt-get update && apt-get install python-lxml
9+
FROM python:2.7.14-jessie
1710

18-
RUN pip install --upgrade pip
11+
COPY --from=build /deps/* /deps/
12+
COPY requirements.txt production.ini /app/
1913

20-
RUN pip --no-cache-dir install -r /app/requirements.txt && \
21-
pip --no-cache-dir install -f file:///tmp/pypa -U booksoai
14+
RUN apt-get update && \
15+
apt-get install python-lxml
16+
RUN pip install --upgrade pip && pip install waitress
17+
RUN pip install --no-cache-dir -r /app/requirements.txt && \
18+
pip install --no-index --find-links=file:///deps -U booksoai
19+
RUN rm -rf /deps
2220

23-
RUN rm -rf /tmp/pypa
21+
WORKDIR /app
2422

2523
USER nobody
2624
EXPOSE 6543
2725

2826
CMD gunicorn --paste /app/production.ini
29-

booksoai/oaipmh.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from __future__ import unicode_literals
22

3-
import plumber
4-
5-
from lxml import etree
63
from datetime import datetime
74

5+
import plumber
86
import pipeline
97

108

booksoai/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ def transform(self, item):
219219
title = etree.SubElement(oai_rec, '{%s}title' % self.dc)
220220
title.text = data.get('title')
221221

222-
for author_role in ['individual_author', 'corporate_author', 'organizer', 'coordinator']:
222+
for author_role in ['individual_author', 'corporate_author', 'organizer', 'coordinator', 'editor']:
223223
for ar in data.get('creators', {}).get(author_role, []):
224224
self._append_node(oai_rec, '{%s}creator' % self.dc, ar[0])
225225

226-
for contributor_role in ['editor', 'collaborator', 'translator']:
226+
for contributor_role in ['collaborator', 'translator']:
227227
for cr in data.get('creators', {}).get(contributor_role, []):
228228
self._append_node(oai_rec, '{%s}contributor' % self.dc, cr[0])
229229

booksoai/tests/test_pipeline.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def test_metadata_pipe_add_record_as_dublin_core_with_translator_contributor(sel
551551

552552
self.assertEqual(etree.tostring(xml), xml_str)
553553

554-
def test_metadata_pipe_add_record_as_dublin_core_with_editor_contributor(self):
554+
def test_metadata_pipe_add_record_as_dublin_core_with_editor_creator(self):
555555
data = {
556556
'title': 'title',
557557
'creators': {
@@ -579,7 +579,7 @@ def test_metadata_pipe_add_record_as_dublin_core_with_editor_contributor(self):
579579
xml_str += ' xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/'
580580
xml_str += ' http://www.openarchives.org/OAI/2.0/oai_dc.xsd">'
581581
xml_str += '<dc:title>title</dc:title>'
582-
xml_str += '<dc:contributor>editor1</dc:contributor>'
582+
xml_str += '<dc:creator>editor1</dc:creator>'
583583
xml_str += '<dc:description>description</dc:description>'
584584
xml_str += '<dc:publisher>publisher</dc:publisher>'
585585
xml_str += '<dc:date>2014</dc:date>'
@@ -648,10 +648,10 @@ def test_metadata_pipe_add_record_as_dublin_core_with_multiple_contributor_group
648648
['translator1', None],
649649
['translator2', None]
650650
],
651-
'editor': [
652-
['editor1', None],
653-
['editor2', None],
654-
['editor3', None]
651+
'collaborator': [
652+
['collaborator1', None],
653+
['collaborator2', None],
654+
['collaborator3', None]
655655
],
656656
},
657657
'description': 'description',
@@ -674,9 +674,9 @@ def test_metadata_pipe_add_record_as_dublin_core_with_multiple_contributor_group
674674
xml_str += ' xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/'
675675
xml_str += ' http://www.openarchives.org/OAI/2.0/oai_dc.xsd">'
676676
xml_str += '<dc:title>title</dc:title>'
677-
xml_str += '<dc:contributor>editor1</dc:contributor>'
678-
xml_str += '<dc:contributor>editor2</dc:contributor>'
679-
xml_str += '<dc:contributor>editor3</dc:contributor>'
677+
xml_str += '<dc:contributor>collaborator1</dc:contributor>'
678+
xml_str += '<dc:contributor>collaborator2</dc:contributor>'
679+
xml_str += '<dc:contributor>collaborator3</dc:contributor>'
680680
xml_str += '<dc:contributor>translator1</dc:contributor>'
681681
xml_str += '<dc:contributor>translator2</dc:contributor>'
682682
xml_str += '<dc:description>description</dc:description>'
@@ -719,6 +719,10 @@ def test_metadata_pipe_add_record_as_dublin_core_with_multiple_contributor_and_c
719719
['editor2', None],
720720
['editor3', None]
721721
],
722+
'collaborator': [
723+
['collaborator1', None],
724+
['collaborator2', None],
725+
],
722726
'coordinator': [
723727
['coordinator1', None],
724728
['coordinator2', None],
@@ -753,9 +757,11 @@ def test_metadata_pipe_add_record_as_dublin_core_with_multiple_contributor_and_c
753757
xml_str += '<dc:creator>organizer2</dc:creator>'
754758
xml_str += '<dc:creator>coordinator1</dc:creator>'
755759
xml_str += '<dc:creator>coordinator2</dc:creator>'
756-
xml_str += '<dc:contributor>editor1</dc:contributor>'
757-
xml_str += '<dc:contributor>editor2</dc:contributor>'
758-
xml_str += '<dc:contributor>editor3</dc:contributor>'
760+
xml_str += '<dc:creator>editor1</dc:creator>'
761+
xml_str += '<dc:creator>editor2</dc:creator>'
762+
xml_str += '<dc:creator>editor3</dc:creator>'
763+
xml_str += '<dc:contributor>collaborator1</dc:contributor>'
764+
xml_str += '<dc:contributor>collaborator2</dc:contributor>'
759765
xml_str += '<dc:contributor>translator1</dc:contributor>'
760766
xml_str += '<dc:contributor>translator2</dc:contributor>'
761767
xml_str += '<dc:description>description</dc:description>'

0 commit comments

Comments
 (0)