public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH] Simplify a bit of code #2
@ 2013-12-19  6:17 antarus
  0 siblings, 0 replies; only message in thread
From: antarus @ 2013-12-19  6:17 UTC (permalink / raw
  To: gentoo-catalyst

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-19  6:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19  6:17 [gentoo-catalyst] [PATCH] Simplify a bit of code #2 antarus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox