mirror of https://github.com/scrapy/scrapy.git
Improved items set_adaptors method, and added a __repr__ method to AdaptorPipes
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40526
This commit is contained in:
parent
4a16bbf74c
commit
770094697a
|
|
@ -56,6 +56,9 @@ class AdaptorPipe(list):
|
|||
elif callable(other):
|
||||
return AdaptorPipe(self + [other])
|
||||
|
||||
def __repr__(self):
|
||||
return '<AdaptorPipe %s >' % super(AdaptorPipe, self).__repr__()
|
||||
|
||||
def adaptize(adaptor, my_args=None):
|
||||
"""
|
||||
This decorator helps you add to your pipelines adaptors that are able
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ScrapedItem(object):
|
|||
Set the adaptors to use for this item. Receives a dict of the adaptors
|
||||
desired for each attribute and returns the item itself.
|
||||
"""
|
||||
_adaptors_dict = dict(item for item in adaptors_dict.items() if isinstance(item[1], AdaptorPipe))
|
||||
_adaptors_dict = dict((attrib, AdaptorPipe(pipe)) for attrib, pipe in adaptors_dict.items() if hasattr(pipe, '__iter__'))
|
||||
self.__dict__['_adaptors_dict'] = _adaptors_dict
|
||||
return self
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue