From: agaffney Date: Sun, 7 Sep 2008 19:02:03 +0000 (-0500) Subject: Switch commandline spec value parsing to use catalyst.config.ConfigParser X-Git-Tag: CATALYST_2_0_6_916~71 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=c0e08cc438aebc2a5246a9b8f579c586fa60f246;p=catalyst.git Switch commandline spec value parsing to use catalyst.config.ConfigParser --- diff --git a/ChangeLog b/ChangeLog index 2e7caca4..0fb54146 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ # Copyright 2002-2008 Gentoo Foundation; Distributed under the GPL v2 # $Id: $ + 07 Sep 2008; Andrew Gaffney catalyst, + modules/catalyst/config.py, modules/catalyst_support.py: + Switch commandline spec value parsing to use catalyst.config.ConfigParser + 07 Sep 2008; Andrew Gaffney catalyst, modules/catalyst/config.py: A few fixes to ParserBase after actually testing it switch to parsing diff --git a/catalyst b/catalyst index 9b3cf156..08706063 100755 --- a/catalyst +++ b/catalyst @@ -193,14 +193,6 @@ def import_modules(): return targetmap -def do_cli(cmdline): - try: - return arg_parse(cmdline) - - except CatalystError: - print "!!! catalyst: Could not parse commandline, exiting." - sys.exit(1) - def build_target(addlargs, targetmap): try: if not targetmap.has_key(addlargs["target"]): @@ -387,8 +379,14 @@ if __name__ == "__main__": addlargs.update(spec.get_values()) if mycmdline: - addlargs.update(do_cli(mycmdline)) - + try: + cmdline = catalyst.config.ConfigParser() + cmdline.parse_lines(mycmdline) + addlargs.update(cmdline.get_values()) + except CatalystError: + print "!!! catalyst: Could not parse commandline, exiting." + sys.exit(1) + if not addlargs.has_key("target"): raise CatalystError, "Required value \"target\" not specified." diff --git a/modules/catalyst/config.py b/modules/catalyst/config.py index 1f221b89..9315c679 100644 --- a/modules/catalyst/config.py +++ b/modules/catalyst/config.py @@ -83,7 +83,7 @@ class ParserBase: # cur_array += mobjs cur_array += myline.split() else: - raise Exception("Value without a key found on line " + x) + raise CatalystError, "Syntax error: " + x # XXX: Do we really still need this "single value is a string" behavior? if len(cur_array) == 2: diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index b402beed..f110c5da 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -665,20 +665,6 @@ def ismount(path): return 1 return 0 -def arg_parse(cmdline): - #global required_config_file_values - mydict={} - for x in cmdline: - foo=string.split(x,"=",1) - if len(foo)!=2: - raise CatalystError, "Invalid arg syntax: "+x - - else: - mydict[foo[0]]=foo[1] - - # if all is well, we should return (we should have bailed before here if not) - return mydict - def addl_arg_parse(myspec,addlargs,requiredspec,validspec): "helper function to help targets parse additional arguments" global valid_config_file_values