core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)

This commit is contained in:
Goffi 2014-08-27 01:27:05 +02:00
commit cc9bf9f2df

View file

@ -186,3 +186,8 @@ class Const(object):
# XXX: we use a classmethod so we can use Const inheritance to change default options
return(cls.LOG_OPT_COLORS, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT)
@classmethod
def bool(cls, value):
if isinstance(value, bool):
return cls.BOOL_TRUE if value else cls.BOOL_FALSE
return value.lower() == cls.BOOL_TRUE