changeset 1143:3164b509bc99

core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
author Goffi <goffi@goffi.org>
date Wed, 27 Aug 2014 01:27:05 +0200
parents 2f9f735334da
children 2481fa96ac1c
files src/core/constants.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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