Skip to content

Commit

Permalink
introduce 'source' to spiders
Browse files Browse the repository at this point in the history
Signed-off-by: Szymon Łopaciuk <[email protected]>
  • Loading branch information
szymonlopaciuk committed Feb 1, 2018
1 parent 5bd3c5f commit 1c82c2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hepcrawl/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def open_spider(self, spider):
self.results_data = []

def _post_enhance_item(self, item, spider):
source = spider.name
source = spider.source

enhanced_record = item_to_hep(
item=item,
Expand Down
4 changes: 4 additions & 0 deletions hepcrawl/spiders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ class StatefulSpider(Spider):
def __init__(self, *args, **kwargs):
self.state = {}
super(StatefulSpider, self).__init__(*args, **kwargs)

@property
def source(self):
return self.name
1 change: 1 addition & 0 deletions tests/unit/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
def spider():
mock_spider = mock.create_autospec(Spider)
mock_spider.name = 'arXiv'
mock_spider.source = 'arXiv'
mock_spider.state = {}
return mock_spider

Expand Down

0 comments on commit 1c82c2a

Please sign in to comment.