changeset 64:a8013bd3126a

minor bug fixes
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 28 Mar 2012 08:33:54 -0700
parents e7005b75ef8d
children 2a2e9aee5bc6
files configuration/configuration.py tests/example.py
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/configuration/configuration.py	Wed Mar 28 08:29:50 2012 -0700
+++ b/configuration/configuration.py	Wed Mar 28 08:33:54 2012 -0700
@@ -345,14 +345,14 @@
 
         # get CLI configuration options
         cli_config = dict([(key, value) for key, value in options.__dict__.items()
-                           if key in self.options and key in parser.parsed])
+                           if key in self.options and key in self.parsed])
 
         # deserialize configuration
         configuration_files = getattr(options, 'load', args)
         missing = [i for i in configuration_files
                    if not os.path.exists(i)]
         if missing:
-            parser.error("Missing files: %s" % ', '.join(missing))
+            self.error("Missing files: %s" % ', '.join(missing))
         config = []
         for f in configuration_files:
             try:
@@ -378,6 +378,9 @@
             # XXX assuming if you don't have values you were just dumping
             raise missingvalues
 
+        # update options from config
+        options.__dict__.update(self.config)
+
         # return parsed arguments
         return options, args
 
--- a/tests/example.py	Wed Mar 28 08:29:50 2012 -0700
+++ b/tests/example.py	Wed Mar 28 08:33:54 2012 -0700
@@ -21,5 +21,6 @@
         }
 
 if __name__ == '__main__':
-    options, args = ExampleConfiguration().parse()
-
+    from pprint import pprint
+    options, args = ExampleConfiguration().parse_args()
+    pprint(options.__dict__)