[kernel] r10340 - people/waldi/dkt/lib/dkt/config

Bastian Blank waldi at alioth.debian.org
Thu Jan 31 14:51:14 UTC 2008


Author: waldi
Date: Thu Jan 31 14:51:14 2008
New Revision: 10340

Log:
lib/dkt/config/base.py: Add method to parse booleans.


Modified:
   people/waldi/dkt/lib/dkt/config/base.py

Modified: people/waldi/dkt/lib/dkt/config/base.py
==============================================================================
--- people/waldi/dkt/lib/dkt/config/base.py	(original)
+++ people/waldi/dkt/lib/dkt/config/base.py	Thu Jan 31 14:51:14 2008
@@ -34,6 +34,19 @@
             return default
         return o
 
+    def get_parse_boolean(self, section, option, default = _marker):
+        s = self.get(section, option, _marker)
+        if s is _marker:
+            if default is _marker:
+                raise KeyError((section, option))
+            return default
+        s = s.lower()
+        if s in ('true', 'yes', '1'):
+            return True
+        if s in ('false', 'no', '0'):
+            return False
+        raise ValueError((section, option))
+
     def get_section(self, section, default = _marker):
         s = self._sections.get(section, _marker)
         if s is _marker:



More information about the Kernel-svn-changes mailing list