From: Chris Gianelloni Date: Tue, 18 Apr 2006 20:59:12 +0000 (+0000) Subject: Added patch from Andrew Gaffney to re-write parse_spec. This... X-Git-Tag: CATALYST_2_0_6_916~379 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dbce1700b1e7db04d685467cc36da0e0c1a84ad8;p=catalyst.git Added patch from Andrew Gaffney to re-write parse_spec. This should resolve bug #130103, as well as make the code much cleaner. This is 2.0_rc42. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@1115 d1e1f19c-881f-0410-ab34-b69fee027534 --- diff --git a/AUTHORS b/AUTHORS index 255fda1d..4caceae1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -17,3 +17,4 @@ Daniel Ostrow Matsuu Takuto Joshua Kinard Lars Weiler +Andrew Gaffney diff --git a/ChangeLog b/ChangeLog index 7ad01b05..d582b6d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ # Copyright 2002-2006 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.600 2006/04/18 20:57:21 wolf31o2 Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.601 2006/04/18 20:59:12 wolf31o2 Exp $ + + 18 Apr 2006; Chris Gianelloni AUTHORS, catalyst, + modules/catalyst_support.py: + Added patch from Andrew Gaffney to re-write + parse_spec. This should resolve bug #130103, as well as make the code much + cleaner. This is 2.0_rc42. 18 Apr 2006; Chris Gianelloni modules/generic_stage_target.py: diff --git a/catalyst b/catalyst index c86204c5..f436ca79 100755 --- a/catalyst +++ b/catalyst @@ -1,7 +1,7 @@ #!/usr/bin/python -OO # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.149 2006/04/04 16:08:11 wolf31o2 Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.150 2006/04/18 20:59:12 wolf31o2 Exp $ # Maintained in full by: # Eric Edgar @@ -11,7 +11,7 @@ import os,sys,imp,string,getopt import pdb __maintainer__="Chris Gianelloni " -__version__="2.0_rc41" +__version__="2.0_rc42" conf_values={} diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index 3121a723..db679d44 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -1,6 +1,6 @@ # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.68 2006/01/17 20:39:15 rocket Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.69 2006/04/18 20:59:12 wolf31o2 Exp $ import sys,string,os,types,re,signal,traceback,time #import md5,sha @@ -540,75 +540,57 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese """ def parse_spec(mylines): - myspec={} - pos=0 - colon=re.compile(":") - trailing_comment=re.compile("#.*\n") - newline=re.compile("\n") - leading_white_space=re.compile("^\s+") + myspec = {} + cur_array = [] + trailing_comment=re.compile("#.*$") white_space=re.compile("\s+") - while pos0: - + subarray = white_space.split(mobjs[1]) + if subarray: if len(subarray)==1: # Store as a string if only one element is found. # this is to keep with original catalyst behavior # eventually this may go away if catalyst just works # with arrays. - newarray.append(subarray[0]) + cur_array.append(subarray[0]) else: - newarray.append(mobjs[1].split()) + cur_array += subarray # Else add on to the last key we were working on else: - mobjs = white_space.split(mylines[pos]) - for i in mobjs: - newarray.append(i) + mobjs = white_space.split(myline) + cur_array += mobjs - pos += 1 - if len(newarray)==2: - myspec[newarray[0]]=newarray[1] - else: - myspec[newarray[0]]=newarray[1:] + if len(cur_array) == 2: + myspec[cur_array[0]] = cur_array[1] + else: + myspec[cur_array[0]] = cur_array[1:] - for x in myspec.keys(): - # Convert myspec[x] to an array of strings - newarray=[] - if type(myspec[x])!=types.StringType: - for y in myspec[x]: - if type(y)==types.ListType: - newarray.append(y[0]) - if type(y)==types.StringType: - newarray.append(y) - myspec[x]=newarray + for x in myspec: # Delete empty key pairs - if len(myspec[x])==0: + if not myspec[x]: print "\n\tWARNING: No value set for key: "+x print "\tdeleting key: "+x+"\n" del myspec[x]