public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:pending commit in: catalyst/
Date: Sat, 21 Nov 2015 01:33:45 +0000 (UTC)	[thread overview]
Message-ID: <1446050996.d307242bf41554640a8966d79f6f36738d3391ee.dolsen@gentoo> (raw)

commit:     d307242bf41554640a8966d79f6f36738d3391ee
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 27 05:51:52 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 16:49:56 2015 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d307242b

main: extend the -c option to accept multiple files

There's no real reason people can't load multiple config files, so extend
the --config option into --configs and let people specify multiple ones.

 catalyst/defaults.py |  2 ++
 catalyst/main.py     | 55 +++++++++++++++++-----------------------------------
 2 files changed, 20 insertions(+), 37 deletions(-)

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 666afca..c5162d6 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -46,6 +46,8 @@ confdefaults={
 	"storedir": "/var/tmp/catalyst",
 	}
 
+DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
+
 PORT_LOGDIR_CLEAN = \
 	'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
 

diff --git a/catalyst/main.py b/catalyst/main.py
index 9f563cf..176871d 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,7 @@ from DeComp.contents import ContentsMap
 
 from catalyst import log
 import catalyst.config
-from catalyst.defaults import confdefaults, option_messages
+from catalyst.defaults import confdefaults, option_messages, DEFAULT_CONFIG_FILE
 from catalyst.hash_utils import HashMap, HASH_DEFINITIONS
 from catalyst.support import CatalystError
 from catalyst.version import get_version
@@ -36,40 +36,19 @@ def version():
 	log.info('Copyright 2008-2012 various authors')
 	log.info('Distributed under the GNU General Public License version 2.1')
 
-def parse_config(myconfig):
+def parse_config(config_files):
 	# search a couple of different areas for the main config file
 	myconf={}
-	config_file=""
-	default_config_file = '/etc/catalyst/catalyst.conf'
 
-	# first, try the one passed (presumably from the cmdline)
-	if myconfig:
-		if os.path.exists(myconfig):
-			log.notice('Using command line specified Catalyst configuration file: %s',
-				myconfig)
-			config_file=myconfig
-
-		else:
-			log.critical('Specified configuration file does not exist: %s', myconfig)
-
-	# next, try the default location
-	elif os.path.exists(default_config_file):
-		log.notice('Using default Catalyst configuration file: %s',
-			default_config_file)
-		config_file = default_config_file
-
-	# can't find a config file (we are screwed), so bail out
-	else:
-		log.critical('Could not find a suitable configuration file')
-
-	# 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())
-
-	except Exception:
-		log.critical('Could not find parse configuration file: %s', myconfig)
+	# try and parse the config file "config_file"
+	for config_file in config_files:
+		log.notice('Loading configuration file: %s', config_file)
+		try:
+			config = catalyst.config.ConfigParser(config_file)
+			myconf.update(config.get_values())
+		except Exception as e:
+			log.critical('Could not find parse configuration file: %s: %s',
+				config_file, e)
 
 	# now, load up the values into conf_values so that we can use them
 	for x in list(confdefaults):
@@ -209,9 +188,9 @@ $ catalyst -f stage1-specfile.spec"""
 	group.add_argument('-F', '--fetchonly',
 		default=False, action='store_true',
 		help='fetch files only')
-	group.add_argument('-c', '--config',
-		type=FilePath(),
-		help='use specified configuration file')
+	group.add_argument('-c', '--configs',
+		type=FilePath(), action='append',
+		help='use specified configuration files')
 	group.add_argument('-f', '--file',
 		type=FilePath(),
 		help='read specfile')
@@ -241,7 +220,9 @@ def main():
 		color=opts.color)
 
 	# Parse the command line options.
-	myconfig = opts.config
+	myconfigs = opts.configs
+	if not myconfigs:
+		myconfigs = [DEFAULT_CONFIG_FILE]
 	myspecfile = opts.file
 	mycmdline = opts.cli[:]
 
@@ -271,7 +252,7 @@ def main():
 	# made it this far so start by outputting our version info
 	version()
 	# import configuration file and import our main module using those settings
-	parse_config(myconfig)
+	parse_config(myconfigs)
 
 	conf_values["options"].update(options)
 	log.debug('conf_values[options] = %s', conf_values['options'])


             reply	other threads:[~2015-11-21  1:34 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-21  1:33 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-11-22 15:52 [gentoo-commits] proj/catalyst:pending commit in: catalyst/ Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-11  9:35 Brian Dolbec
2017-03-11  7:07 Brian Dolbec
2017-03-10 18:38 Brian Dolbec
2017-03-09 10:02 Brian Dolbec
2017-03-09  9:39 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-09-08 14:14 Brian Dolbec
2015-09-06 21:21 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-06 21:18 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-06 21:18 Brian Dolbec
2015-09-06 20:33 Brian Dolbec
2015-09-05 16:24 Brian Dolbec
2015-09-04 15:20 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  4:50 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-08-30 20:58 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-06-15 20:25 Brian Dolbec
2015-05-24  0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:44 Brian Dolbec
2015-02-26 20:44 Brian Dolbec
2015-02-26 19:25 Brian Dolbec
2015-02-26  4:12 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01  5:59 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2014-09-11  3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-06-14  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-09-11  3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-06-14  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-05-05 19:17 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-04-02 20:09 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446050996.d307242bf41554640a8966d79f6f36738d3391ee.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox