From 1fa947dd678e02e449c033df6b8c2d125fa7311b Mon Sep 17 00:00:00 2001 From: olveyra Date: Wed, 3 Sep 2008 13:53:28 +0000 Subject: [PATCH] - Improved attribute name checks - added support to tuple definition of pipeline --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40202 --- scrapy/trunk/scrapy/item/adaptors.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scrapy/trunk/scrapy/item/adaptors.py b/scrapy/trunk/scrapy/item/adaptors.py index 265fa2fb2..59e192fe4 100644 --- a/scrapy/trunk/scrapy/item/adaptors.py +++ b/scrapy/trunk/scrapy/item/adaptors.py @@ -17,20 +17,23 @@ class Adaptor(object): class AdaptorPipe: - def __init__(self, define_from=None, adaptorclass=None): + def __init__(self, adaptors=None, adaptorclass=None): """ - If "define_from" is given, constructs pipeline from this. - "define_from" is an ordered tuple of triplets, each of which - has the attribute name regex, the adaptor name, and the module - path to the adaptor function. Example: + If "adaptors" is given, constructs pipeline from this. + "define_from" is an ordered tuple of 4-elements tuples, each of which + has the same parameters you give to the insertadaptor method, except + 'after' and 'before', because you define the adaptors order in the tuple. + . Example: ( - ("url", "remove_entities", "scrapy.utils.markup.remove_entities") - (".*", "replace_tags", "scrapy.utils.markup.replace_tags") + ("my_function", "my_function", None, "name") ... ) """ self.__adaptorspipe = [] self.__adaptorclass = adaptorclass or Adaptor + if adaptors: + for entry in adaptors: + self.insertadaptor(*entry) @property def adaptors_names(self):