public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: antarus@gentoo.org
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] [PATCH] Simplify a bit of code #2
Date: Wed, 18 Dec 2013 22:17:28 -0800	[thread overview]
Message-ID: <1387433848-31145-1-git-send-email-antarus@gentoo.org> (raw)

From: Alec Warner <antarus@gentoo.org>

The docstring was wrong, so fix that.
If we can open the file (no EnvironmentError raised) we may still fail
to parse the file. That was previously guarded by a bare except:, so add
that back so we do not introduce any new behavior.
Fix dangling reference to myconfig; it will cause a crash.
---
 catalyst | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/catalyst b/catalyst
index 47efb90..ab69778 100755
--- a/catalyst
+++ b/catalyst
@@ -58,7 +58,7 @@ def version():
 	print "Distributed under the GNU General Public License version 2.1\n"
 
 def parse_config(config_path):
-	"""Parse the catalyst config file and generate a targetmap.
+	"""Parse the catalyst config file and update conf_values.
 
 	TODO(antarus): DANGER: This file modifies global state (conf_values).
 
@@ -91,12 +91,11 @@ def parse_config(config_path):
 		# TODO(antarus): it should be discouraged to call sys.exit() from functions.
 		# One should call sys.exit() from main()..this isn't main().
 		sys.exit(1)
-
-	try:
-		myconf.update(cfg.get_values())
 	except:
-		print "!!! catalyst: Unable to parse configuration file, "+myconfig
+		print "!!! catalyst: Unable to parse catalyst configuration: %s" config_path
 		sys.exit(1)
+		
+	myconf.update(cfg.get_values())
 
 	# now, load up the values into conf_values so that we can use them
 	for x in confdefaults.keys():
-- 
1.8.1.2



                 reply	other threads:[~2013-12-19  6:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1387433848-31145-1-git-send-email-antarus@gentoo.org \
    --to=antarus@gentoo.org \
    --cc=gentoo-catalyst@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