changeset 101:f4590492cb4c

handle load option a bit better
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 30 Apr 2012 13:21:48 -0700
parents aa5c663dd8b7
children c530f6265deb
files configuration/configuration.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/configuration/configuration.py	Mon Apr 30 13:06:03 2012 -0700
+++ b/configuration/configuration.py	Mon Apr 30 13:21:48 2012 -0700
@@ -223,7 +223,8 @@
 class Configuration(optparse.OptionParser):
     """declarative configuration object"""
 
-    options = {} # configuration basis
+    options = {}         # configuration basis definition
+    load_option = 'load' # where to put the load option
 
     def __init__(self, configuration_providers=configuration_providers, types=types, load=None, dump='--dump', **parser_args):
 
@@ -260,7 +261,7 @@
         # add option(s) for configuration_providers
         if load:
             self.add_option(load,
-                            dest='load', action='append',
+                            dest=self.load_option, action='append',
                             help="load configuration from a file")
 
         # add an option for dumping
@@ -394,7 +395,11 @@
                            if key in self.option_dict and key in self.parsed])
 
         # deserialize configuration
-        configuration_files = getattr(options, 'load', args)
+        configuration_files = getattr(options, self.load_option, args)
+        if not configuration_files:
+            configuration_files = []
+        if isinstance(configuration_files, basestring):
+            configuration_files = [configuration_files]
         missing = [i for i in configuration_files
                    if not os.path.exists(i)]
         if missing: