Switch commandline spec value parsing to use catalyst.config.ConfigParser
authoragaffney <agaffney@kagome.(none)>
Sun, 7 Sep 2008 19:02:03 +0000 (14:02 -0500)
committeragaffney <agaffney@kagome.(none)>
Sun, 7 Sep 2008 19:02:03 +0000 (14:02 -0500)
ChangeLog
catalyst
modules/catalyst/config.py
modules/catalyst_support.py

index 2e7caca4b8b5be0f3354d7d23b42dc9c4342d0c1..0fb54146465f2e2ab1de2fae916d2993dbb86d04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 # 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
index 9b3cf15691bcd55980bcb12099424131bbdab7fc..08706063ef549049dbb5627916f4583ca87d9996 100755 (executable)
--- 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."
 
index 1f221b89333cdea44f93a676b8d1515fb7dad40d..9315c6798669c1b423818616b3ac25f274909566 100644 (file)
@@ -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:
index b402beed7312b82ae04f0d89d39c6b61bd1cfb4e..f110c5da5e8cbebe462b180150c1ac19652cbdd7 100644 (file)
@@ -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