conftypes: cleanup
This commit is contained in:
parent
309ecb95c8
commit
0766116424
@ -319,9 +319,8 @@ class IntList(List):
|
|||||||
vals = self.transform(value)
|
vals = self.transform(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValidationError(value, "must be a list of integers!")
|
raise ValidationError(value, "must be a list of integers!")
|
||||||
for v in vals:
|
if None in vals and not self.none_ok:
|
||||||
if v is None and not self.none_ok:
|
raise ValidationError(value, "items may not be empty!")
|
||||||
raise ValidationError(value, "items may not be empty!")
|
|
||||||
|
|
||||||
|
|
||||||
class Float(BaseType):
|
class Float(BaseType):
|
||||||
@ -894,8 +893,8 @@ class WebKitBytesList(List):
|
|||||||
vals = super().transform(value)
|
vals = super().transform(value)
|
||||||
for val in vals:
|
for val in vals:
|
||||||
self.bytestype.validate(val)
|
self.bytestype.validate(val)
|
||||||
if any(val is None for val in vals):
|
if None in vals and not self.none_ok:
|
||||||
raise ValidationError(value, "all values need to be set!")
|
raise ValidationError(value, "items may not be empty!")
|
||||||
if self.length is not None and len(vals) != self.length:
|
if self.length is not None and len(vals) != self.length:
|
||||||
raise ValidationError(value, "exactly {} values need to be "
|
raise ValidationError(value, "exactly {} values need to be "
|
||||||
"set!".format(self.length))
|
"set!".format(self.length))
|
||||||
@ -936,9 +935,7 @@ class ZoomPerc(Perc):
|
|||||||
|
|
||||||
"""A percentage which needs to be in the current zoom percentages."""
|
"""A percentage which needs to be in the current zoom percentages."""
|
||||||
|
|
||||||
def validate(self, value):
|
# FIXME we should validate the percentage is in the list here.
|
||||||
super().validate(value)
|
|
||||||
# FIXME we should validate the percentage is in the list here.
|
|
||||||
|
|
||||||
|
|
||||||
class HintMode(BaseType):
|
class HintMode(BaseType):
|
||||||
@ -1086,6 +1083,10 @@ class AutoSearch(BaseType):
|
|||||||
('dns', "Use DNS requests (might be slow!)."),
|
('dns', "Use DNS requests (might be slow!)."),
|
||||||
('false', "Never search automatically."))
|
('false', "Never search automatically."))
|
||||||
|
|
||||||
|
def __init__(self, none_ok=False):
|
||||||
|
super().__init__(none_ok)
|
||||||
|
self.booltype = Bool()
|
||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
if not value:
|
if not value:
|
||||||
if self.none_ok:
|
if self.none_ok:
|
||||||
@ -1095,7 +1096,7 @@ class AutoSearch(BaseType):
|
|||||||
if value.lower() in ('naive', 'dns'):
|
if value.lower() in ('naive', 'dns'):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
Bool.validate(self, value)
|
self.booltype.validate(value)
|
||||||
|
|
||||||
def transform(self, value):
|
def transform(self, value):
|
||||||
if not value:
|
if not value:
|
||||||
|
Loading…
Reference in New Issue
Block a user