From 4ede33a46dbfac083fb20447ee7449589eb82412 Mon Sep 17 00:00:00 2001 From: elpolilla Date: Mon, 20 Oct 2008 13:35:23 +0000 Subject: [PATCH] Fixed some bugs in the single attributes pipeline generator --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40320 --- scrapy/trunk/scrapy/item/adaptors.py | 32 +++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/scrapy/trunk/scrapy/item/adaptors.py b/scrapy/trunk/scrapy/item/adaptors.py index 9004fc8d3..17cd58644 100644 --- a/scrapy/trunk/scrapy/item/adaptors.py +++ b/scrapy/trunk/scrapy/item/adaptors.py @@ -200,16 +200,18 @@ def delist(value): The following methods automatically generate adaptor pipelines for some basic datatypes, according to the parameters you pass them. """ -def single_pipeline(do_unquote=True): +def single_pipeline(remove_root=True, remove_tags=True, do_unquote=True): pipe = [ extract, unique, to_unicode, drop_empty_elements, - remove_tags, - remove_root, remove_multispaces, strip, ] + if remove_root: + pipe.insert(4, remove_root) + if remove_tags: + pipe.insert(5, remove_tags) if do_unquote: pipe.append(unquote) return pipe + [delist] @@ -221,19 +223,19 @@ def url_pipeline(): drop_empty_elements, ] -def list_pipeline(extract=True): +def list_pipeline(do_extract=True): pipe = [] - if extract: - pipe.append(extract) - return pipe.extend([ unique, - to_unicode, - drop_empty_elements, - unquote, - remove_tags, - remove_root, - strip, - ]) + if do_extract: + pipe.append(extract) + return pipe + [ unique, + to_unicode, + drop_empty_elements, + unquote, + remove_tags, + remove_root, + strip, + ] def list_join_pipeline(delimiter='\t'): return list_pipeline() + [delimiter.join] - \ No newline at end of file +