Gentoo Archives: gentoo-catalyst

From: antarus@g.o
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH] Simplify a bit of code #2
Date: Thu, 19 Dec 2013 06:17:12
Message-Id: 1387433848-31145-1-git-send-email-antarus@gentoo.org
1 From: Alec Warner <antarus@g.o>
2
3 The docstring was wrong, so fix that.
4 If we can open the file (no EnvironmentError raised) we may still fail
5 to parse the file. That was previously guarded by a bare except:, so add
6 that back so we do not introduce any new behavior.
7 Fix dangling reference to myconfig; it will cause a crash.
8 ---
9 catalyst | 9 ++++-----
10 1 file changed, 4 insertions(+), 5 deletions(-)
11
12 diff --git a/catalyst b/catalyst
13 index 47efb90..ab69778 100755
14 --- a/catalyst
15 +++ b/catalyst
16 @@ -58,7 +58,7 @@ def version():
17 print "Distributed under the GNU General Public License version 2.1\n"
18
19 def parse_config(config_path):
20 - """Parse the catalyst config file and generate a targetmap.
21 + """Parse the catalyst config file and update conf_values.
22
23 TODO(antarus): DANGER: This file modifies global state (conf_values).
24
25 @@ -91,12 +91,11 @@ def parse_config(config_path):
26 # TODO(antarus): it should be discouraged to call sys.exit() from functions.
27 # One should call sys.exit() from main()..this isn't main().
28 sys.exit(1)
29 -
30 - try:
31 - myconf.update(cfg.get_values())
32 except:
33 - print "!!! catalyst: Unable to parse configuration file, "+myconfig
34 + print "!!! catalyst: Unable to parse catalyst configuration: %s" config_path
35 sys.exit(1)
36 +
37 + myconf.update(cfg.get_values())
38
39 # now, load up the values into conf_values so that we can use them
40 for x in confdefaults.keys():
41 --
42 1.8.1.2