Allow multiple ini files to be specified on the command line
This commit is contained in:
parent
6468d23e73
commit
6481eaf5a8
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user