Skip to content

Commit

Permalink
Merge pull request #177 from iulianav/refactor-tohep-according-to-schema
Browse files Browse the repository at this point in the history
Generate 'acquisition_source' with literature builder only
  • Loading branch information
david-caro authored Sep 20, 2017
2 parents e749a26 + 880476e commit 9b96510
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 9b96510

Please sign in to comment.