- def __add__(self, other):
- return float(self) + float(other)
-
- def __sub__(self, other):
- return float(self) - float(other)
-
- def __cmp__(self, other):
- return float(self) - float(other)
-
-class BoolSetting(BaseSetting):
- def _parse(self, value):
- return bool(value)
-
-class Setting(object):
- sets = {}
-
- def __new__(cls, name, default, set=None, field_context={}):
- if isinstance(default, bool):
- instance = BoolSetting(name, default, field_context)
- elif isinstance(default, str):
- instance = StringSetting(name, default, field_context)
- elif isinstance(default, float):
- instance = FloatSetting(name, default, field_context)
- elif isinstance(default, int):
- instance = IntegerSetting(name, default, field_context)
- else:
- instance = BaseSetting(name, default, field_context)
-
- if set is not None:
- if not set.name in cls.sets:
- cls.sets[set.name] = set