Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Define your item pipelines here
- #
- # Don't forget to add your pipeline to the ITEM_PIPELINES setting
- # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
- import sys
- class BoroughscrperPipeline(object):
- def process_item(self, item, spider):
- def check_spider_pipeline(process_item_method):
- @functools.wraps(process_item_method)
- def wrapper(self, item, spider):
- # message template for debugging
- msg = '%%s %s pipeline step' % (self.__class__.__name__,)
- # if class is in the spider pipeline then use use process_item normally
- if self.__class__ in spider.pipeline:
- spider.log(msg % 'executing', level=log.DEBUG)
- return process_item_method(self, item, spider)
- # otherwise return the untouched item
- else:
- spider.log(msg % 'skipping', level=log.DEBUG)
- return item
- return wrapper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement