mirror of https://github.com/scrapy/scrapy.git
New and simpler implementation of BooleanField
This commit is contained in:
parent
55d922a4b0
commit
0cc289ac84
|
|
@ -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}$')
|
||||
|
|
|
|||
Loading…
Reference in New Issue