# HG changeset patch # User Goffi # Date 1409095625 -7200 # Node ID 3164b509bc99c7a16a9e50a131aa2553ae89a33c # Parent 2f9f735334da93445caab7a5ca2de62c3dc28007 core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions) diff -r 2f9f735334da -r 3164b509bc99 src/core/constants.py --- a/src/core/constants.py Wed Aug 27 01:24:26 2014 +0200 +++ b/src/core/constants.py Wed Aug 27 01:27:05 2014 +0200 @@ -186,3 +186,8 @@ # 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