From 6481eaf5a816533489a775aa83974a0b65b506c8 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Fri, 11 Feb 2011 07:58:14 -0500 Subject: [PATCH] Allow multiple ini files to be specified on the command line --- planet.py | 6 +++--- planet/config.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/planet.py b/planet.py index 73eadc4..26191bb 100755 --- a/planet.py +++ b/planet.py @@ -17,7 +17,7 @@ __license__ = "Python" import os, sys if __name__ == "__main__": - config_file = "config.ini" + config_file = [] offline = 0 verbose = 0 only_if_new = 0 @@ -54,10 +54,10 @@ if __name__ == "__main__": print >>sys.stderr, "Unknown option:", arg sys.exit(1) else: - config_file = arg + config_file.append(arg) from planet import config - config.load(config_file) + config.load(config_file or 'config.ini') if verbose: import planet diff --git a/planet/config.py b/planet/config.py index d36899f..b8fb23d 100644 --- a/planet/config.py +++ b/planet/config.py @@ -134,11 +134,11 @@ def __init__(): define_tmpl('filter', None) define_tmpl('exclude', None) -def load(config_file): +def load(config_files): """ initialize and load a configuration""" global parser parser = ConfigParser() - parser.read(config_file) + parser.read(config_files) import config, planet from planet import opml, foaf, csv_config @@ -157,8 +157,11 @@ def load(config_file): dirs = config.template_directories() if theme_dir not in dirs: dirs.append(theme_dir) - if os.path.dirname(config_file) not in dirs: - dirs.append(os.path.dirname(config_file)) + if not hasattr(config_files, 'append'): + config_files = [config_files] + for config_file in config_files: + if os.path.dirname(config_file) not in dirs: + dirs.append(os.path.dirname(config_file)) # read in the theme parser = ConfigParser() @@ -172,7 +175,7 @@ def load(config_file): # merge configurations, allowing current one to override theme template_files = config.template_files() parser.set('Planet','template_files','') - parser.read(config_file) + parser.read(config_files) for file in config.bill_of_materials(): if not file in bom: bom.append(file) parser.set('Planet', 'bill_of_materials', ' '.join(bom))