From: Andrew Gaffney Date: Sun, 11 Jan 2009 18:11:54 +0000 (-0600) Subject: Load defaults into myconf before parsing config X-Git-Tag: CATALYST-2.0.10~3^2~210 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=24eaf899bb0fc38efc49f934690bf94486bdc38b;p=catalyst.git Load defaults into myconf before parsing config --- diff --git a/catalyst b/catalyst index f427c233..a9b1109a 100755 --- a/catalyst +++ b/catalyst @@ -55,24 +55,26 @@ def show_version(): def parse_config(myconfig): # search a couple of different areas for the main config file - myconf={} - config_file="" - - confdefaults={ "storedir":"/var/tmp/catalyst",\ - "sharedir":"/usr/share/catalyst","distdir":"/usr/portage/distfiles",\ - "portdir":"/usr/portage","options":"",\ - "snapshot_cache":"/var/tmp/catalyst/snapshot_cache",\ - "hash_function":"crc32"} + myconf = {} + config_file = "" + + confdefaults = { + "storedir": "/var/tmp/catalyst", + "sharedir": "/usr/share/catalyst", + "distdir": "/usr/portage/distfiles", + "portdir": "/usr/portage", + "options": "", + "snapshot_cache": "/var/tmp/catalyst/snapshot_cache", + "hash_function": "crc32" + } # first, try the one passed (presumably from the cmdline) if myconfig: if os.path.exists(myconfig): - print "Using command line specified Catalyst configuration file, "+myconfig - config_file=myconfig - + print "Using command line specified Catalyst configuration file, " + myconfig + config_file = myconfig else: - print "!!! catalyst: Could not use specified configuration file "+\ - myconfig + print "!!! catalyst: specified configuration file " + myconfig + " does not exist" sys.exit(1) # next, try the default location @@ -85,9 +87,13 @@ def parse_config(myconfig): print "!!! catalyst: Could not find a suitable configuration file" sys.exit(1) + # Load the default config values into myconf + for x in confdefaults: + print "Setting " + x + " to default value \"" + confdefaults[x] + "\"" + myconf[x] = confdefaults[x] + # now, try and parse the config file "config_file" try: -# execfile(config_file, myconf, myconf) myconfig = catalyst.config.ConfigParser(config_file) myconf.update(myconfig.get_values())