From 0bbd128fca6e2276fc660e083b6d22f220d502a7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 20 Apr 2014 19:25:15 +0200 Subject: [PATCH] Add Float conftype --- qutebrowser/config/conftypes.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qutebrowser/config/conftypes.py b/qutebrowser/config/conftypes.py index c8edfc5a4..c7589659f 100644 --- a/qutebrowser/config/conftypes.py +++ b/qutebrowser/config/conftypes.py @@ -164,6 +164,22 @@ class Int(BaseType): raise ValidationError(value, "must be an integer!") +class Float(BaseType): + + """Base class for an float setting.""" + + typestr = 'float' + + def transform(self, value): + return float(value) + + def validate(self, value): + try: + float(value) + except ValueError: + raise ValidationError(value, "must be a float!") + + class List(BaseType): """Base class for a (string-)list setting."""