From 880476e7ea97b1edea6e0a777e5705d2e24c1a2d Mon Sep 17 00:00:00 2001 From: Iuliana Voinea Date: Wed, 20 Sep 2017 13:23:01 +0200 Subject: [PATCH] Generate 'acquisition_source' with literature builder only 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 --- hepcrawl/tohep.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hepcrawl/tohep.py b/hepcrawl/tohep.py index 9dca5433..8fcbc735 100644 --- a/hepcrawl/tohep.py +++ b/hepcrawl/tohep.py @@ -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, @@ -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,