diff options
author | Matthew Waters <matthew@centricular.com> | 2015-11-03 14:40:17 +1100 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2015-11-03 18:17:19 +1100 |
commit | e40951bff4ab54c7fa83fdf68f7280178cf33552 (patch) | |
tree | 7657c7c2376ed6e15ecd25b8425ce45dbec55e0e | |
parent | 81b0319b5a05cbd60899ff0a708de9b1a69a7541 (diff) |
cerbero: add support for multiple config file arguments
Allows nesting certain configuration operations. e.g. modifying home_dir in one
file, the configured target/arch in another and setting the build-tools sources
directory in another.
When multiple options are specified, the last one one wins.
https://bugzilla.gnome.org/show_bug.cgi?id=757511
-rw-r--r-- | cerbero/config.py | 24 | ||||
-rw-r--r-- | cerbero/main.py | 2 |
2 files changed, 13 insertions, 13 deletions
diff --git a/cerbero/config.py b/cerbero/config.py index a510f956..285df290 100644 --- a/cerbero/config.py +++ b/cerbero/config.py @@ -427,18 +427,18 @@ class Config (object): DEFAULT_CONFIG_FILE m.warning(msg) - def _load_cmd_config(self, filename): - if filename is not None: - - if not os.path.exists(filename): - filename = os.path.join(CONFIG_DIR, filename + "." + CONFIG_EXT) - - if os.path.exists(filename): - self._parse(filename, reset=False) - self.filename = DEFAULT_CONFIG_FILE - else: - raise ConfigurationError(_("Configuration file %s doesn't " - "exists") % filename) + def _load_cmd_config(self, filenames): + if filenames is not None: + for f in filenames: + if not os.path.exists(f): + f = os.path.join(CONFIG_DIR, f + "." + CONFIG_EXT) + + if os.path.exists(f): + self._parse(f, reset=False) + self.filename = DEFAULT_CONFIG_FILE + else: + raise ConfigurationError(_("Configuration file %s doesn't " + "exists") % f) def _load_platform_config(self): platform_config = os.path.join(self.environ_dir, '%s.config' % diff --git a/cerbero/main.py b/cerbero/main.py index 6412fd9d..5a503be5 100644 --- a/cerbero/main.py +++ b/cerbero/main.py @@ -76,7 +76,7 @@ class Main(object): def create_parser(self): ''' Creates the arguments parser ''' self.parser = argparse.ArgumentParser(description=_(description)) - self.parser.add_argument('-c', '--config', type=str, default=None, + self.parser.add_argument('-c', '--config', action='append', type=str, default=None, help=_('Configuration file used for the build')) def parse_arguments(self, args): |