r168 - branches/rewrite/src

Otavio Salvador partial-mirror-devel@lists.alioth.debian.org
Tue, 06 Jul 2004 18:34:51 -0600


Author: otavio
Date: Tue Jul  6 18:34:50 2004
New Revision: 168

Modified:
   branches/rewrite/src/Config.py
Log:
Change the way of process the options to property cast it.

Modified: branches/rewrite/src/Config.py
==============================================================================
--- branches/rewrite/src/Config.py	(original)
+++ branches/rewrite/src/Config.py	Tue Jul  6 18:34:50 2004
@@ -122,6 +122,17 @@
         'sections': 'list',
         }
 
+    def __castOption(self, option, value):
+        if option in self._options_with_type:
+            if self._options_with_type[option] == 'list':
+                return value.split()
+            elif self._options_with_type[option] == 'boolean':
+                return bool(value)
+#            elif self._options_with_type[option] == 'dict':
+#                return map(value.split())
+        else:
+            return value
+
     def __init__(self, filename):
         ConfigParser.__init__(self)
         self.read(filename)
@@ -156,6 +167,7 @@
                 raise InvalidSection(section)
             
 	    for item, value in self.items(section):
+                value = self.__castOption(item, value)
 		if item not in allowed_in_section:
 		    for allowed_key in allowed_in_section:
 			# check the allowed_in_backend keys with