summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Ruby <rubys@intertwingly.net>2011-02-11 07:58:14 -0500
committerSam Ruby <rubys@intertwingly.net>2011-02-11 07:58:14 -0500
commit6481eaf5a816533489a775aa83974a0b65b506c8 (patch)
tree70e7704814aa2b6e977ed4b5d42bd84ce6686ff4
parent6468d23e7396d593599b6d38eebf70b1d9f294e9 (diff)
downloadplanetpixels-6481eaf5a816533489a775aa83974a0b65b506c8.tar.gz
planetpixels-6481eaf5a816533489a775aa83974a0b65b506c8.tar.bz2
Allow multiple ini files to be specified on the command line
-rwxr-xr-xplanet.py6
-rw-r--r--planet/config.py13
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))