# HG changeset patch # User Jeff Hammel # Date 1379473996 25200 # Node ID bb0f58ae318ee74e8754cdebf6a279cd2bb3aa8b # Parent 90cb8aedecbb28c44cac9097299abba60a41f131 configuration/configuration.py diff -r 90cb8aedecbb -r bb0f58ae318e configuration/configuration.py --- a/configuration/configuration.py Tue Sep 17 18:57:25 2013 -0700 +++ b/configuration/configuration.py Tue Sep 17 20:13:16 2013 -0700 @@ -578,21 +578,20 @@ class UserConfiguration(Configuration): """`Configuration` class driven by a config file in user-space""" - - # default configuration file - default_config_file = os.path.join('~', '.mozutils') - default_config_file_path = os.path.expanduser(default_config_file) - usage = '%prog [options] patch <...>' - load_help = 'load from config file' - if os.path.exists(os.path.expanduser(default_config_file)): - load_help += ' [DEFAULT: %s]' % default_config_file - # configuration items to interpolate as paths # TODO: moar bettur! paths = [] - def __init__(self): - Configuration.__init__(self, usage=self.usage, load='--config') + def __init__(self, config=None, load='--config'): + + # default configuration file + self.config_name = config or '.' + os.path.splitext(sys.argv[0])[0] + self.default_config_file = os.path.join('~', self.config_name) + self.default_config_file_path = os.path.expanduser(self.default_config_file) + if os.path.exists(self.default_config_file_path) + self.load_help += ' [DEFAULT: %s]' % default_config_file + + Configuration.__init__(self, usage=self.usage, load=load) def validate(self): Configuration.validate(self) @@ -603,7 +602,7 @@ configuration_files = Configuration.configuration_files(self, options, args) if not configuration_files: # load user config only if no config provided - if os.path.exists(self.default_config_path): + if os.path.exists(self.default_config_file_path): configuration_files = [default_config] return configuration_files