pgtoolkit/config.py
changeset 17 f768a3529ee7
parent 10 f3a1b9792cc9
--- a/pgtoolkit/config.py	Mon Nov 21 10:43:37 2011 +0100
+++ b/pgtoolkit/config.py	Mon Nov 21 10:47:24 2011 +0100
@@ -9,6 +9,7 @@
 
     def add_argument(self, name, type=str, default=None):
         self.registered_args[name] = {'type':type, 'default':default}
+        self.args[name] = default
 
     def load(self, fname):
         # parse config file
@@ -25,14 +26,14 @@
             if key in self.registered_args:
                 # arg registered, check type
                 type = self.registered_args[key]['type']
-                if not isinstance(self.args[key], type):
+                if not isinstance(self.args[key], type) and not self.args[key] is None:
                     ok = False
                     self.log.error("Bad type of config parameter '%s': is %s but should be %s",
                         key, type(self.args[key]), type)
             else:
                 # arg not registered
-                    ok = False
-                    self.log.error("Unknown config parameter '%s'.", key)
+                ok = False
+                self.log.error("Unknown config parameter '%s'.", key)
         return ok
 
     def __getattr__(self, name):