From 0cc289ac84cdbe2bbf375f663b2671d8507d5cbc Mon Sep 17 00:00:00 2001 From: Ismael Carnales Date: Thu, 21 May 2009 14:51:50 +0000 Subject: [PATCH] New and simpler implementation of BooleanField --- scrapy/contrib_exp/newitem/fields.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scrapy/contrib_exp/newitem/fields.py b/scrapy/contrib_exp/newitem/fields.py index e0a47b593..7c82c83d4 100644 --- a/scrapy/contrib_exp/newitem/fields.py +++ b/scrapy/contrib_exp/newitem/fields.py @@ -51,11 +51,7 @@ class MultiValuedField(Field): class BooleanField(Field): def to_python(self, value): - if value is None: return False - if value in (True, False): return value - if value in ('t', 'True', '1'): return True - if value in ('f', 'False', '0'): return False - raise FieldValueError("This value must be either True or False.") + return bool(value) ansi_date_re = re.compile(r'^\d{4}-\d{1,2}-\d{1,2}$')