# Copyright 2002-2008 Gentoo Foundation; Distributed under the GPL v2
# $Id: $
+ 07 Sep 2008; Andrew Gaffney <agaffney@gentoo.org> catalyst,
+ modules/catalyst/config.py, modules/catalyst_support.py:
+ Switch commandline spec value parsing to use catalyst.config.ConfigParser
+
07 Sep 2008; Andrew Gaffney <agaffney@gentoo.org> catalyst,
modules/catalyst/config.py:
A few fixes to ParserBase after actually testing it switch to parsing
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"]):
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."
# 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:
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