Skip to content

Commit

Permalink
Generate 'acquisition_source' with literature builder only
Browse files Browse the repository at this point in the history
I removed the redundant function that was used to generate
the 'acquisition_source' and replaced it with the LiteratureBuilder
'add_acquisition_source' method.

Signed-off-by: Iuliana Voinea <[email protected]>
  • Loading branch information
Iuliana Voinea committed Sep 20, 2017
1 parent e749a26 commit 880476e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions hepcrawl/tohep.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,6 @@ def _normalize_hepcrawl_record(item, source):
return item


def _generate_acquisition_source(source):
acquisition_source = {
'source': source,
'method': 'hepcrawl',
'datetime': datetime.datetime.now().isoformat(),
'submission_number': os.environ.get('SCRAPY_JOB', ''),
}
return acquisition_source


def item_to_hep(
item,
source,
Expand All @@ -167,10 +157,19 @@ def item_to_hep(
Raises:
UnknownItemFormat: if the source item format is unknown.
"""
item.record['acquisition_source'] = _generate_acquisition_source(
builder = LiteratureBuilder(
source=source
)

builder.add_acquisition_source(
source=source,
method='hepcrawl',
date=datetime.datetime.now().isoformat(),
submission_number=os.environ.get('SCRAPY_JOB', ''),
)

item.record['acquisition_source'] = builder.record['acquisition_source']

if item.record_format == 'hep':
return hep_to_hep(
hep_record=item.record,
Expand Down

0 comments on commit 880476e

Please sign in to comment.