# HG changeset patch # User Jeff Hammel # Date 1335817308 25200 # Node ID f4590492cb4c07ce5657d2ad4754961d7c3ec555 # Parent aa5c663dd8b78f4aa031b5b347c0567db1e813e9 handle load option a bit better diff -r aa5c663dd8b7 -r f4590492cb4c configuration/configuration.py --- 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: