Added patch from Andrew Gaffney <agaffney@gentoo.org> to re-write parse_spec. This...
authorChris Gianelloni <wolf31o2@gentoo.org>
Tue, 18 Apr 2006 20:59:12 +0000 (20:59 +0000)
committerChris Gianelloni <wolf31o2@gentoo.org>
Tue, 18 Apr 2006 20:59:12 +0000 (20:59 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@1115 d1e1f19c-881f-0410-ab34-b69fee027534

AUTHORS
ChangeLog
catalyst
modules/catalyst_support.py

diff --git a/AUTHORS b/AUTHORS
index 255fda1dd73195ad3a29574cba8bf714a922bfd0..4caceae155570a5d9d6bdcd4e522de2a05d36552 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -17,3 +17,4 @@ Daniel Ostrow <dostrow@gentoo.org>
 Matsuu Takuto <matsuu@gentoo.org>
 Joshua Kinard <kumba@gentoo.org>
 Lars Weiler <pylon@gentoo.org>
+Andrew Gaffney <agaffney@gentoo.org>
index 7ad01b0586297118d8098b1d26d7947588bb8cd7..d582b6d0a67b5553d447d0120f356806ff3a66a0 100644 (file)
--- 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 <wolf31o2@gentoo.org> AUTHORS, catalyst,
+  modules/catalyst_support.py:
+  Added patch from Andrew Gaffney <agaffney@gentoo.org> 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 <wolf31o2@gentoo.org>
   modules/generic_stage_target.py:
index c86204c5b5502d2862af85837ac90d14bba590b8..f436ca791835f00f1349c1ad5acc5d2508636ad1 100755 (executable)
--- 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 <rocket@gentoo.org>
@@ -11,7 +11,7 @@ import os,sys,imp,string,getopt
 import pdb
 
 __maintainer__="Chris Gianelloni <wolf31o2@gentoo.org>"
-__version__="2.0_rc41"
+__version__="2.0_rc42"
 
 conf_values={}
 
index 3121a7230b640aaa4574d39f2e3e2ee783bcd541..db679d44ce0ae1d1b260a488f882870d2487c2ec 100644 (file)
@@ -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 pos<len(mylines):
+       while len(mylines):
+               myline = mylines.pop(0).strip()
+
                # Force the line to be clean 
                # Remove Comments ( anything following # )
-               mylines[pos]=trailing_comment.sub("",mylines[pos])
-               
-               # Remove newline character \n
-               mylines[pos]=newline.sub("",mylines[pos])
+               myline = trailing_comment.sub("", myline)
 
-               # Remove leading white space
-               mylines[pos]=leading_white_space.sub("",mylines[pos])
-               
                # Skip any blank lines
-               if len(mylines[pos])<=1:
-                       pos += 1
-                       continue
-               msearch=colon.search(mylines[pos])
+               if not myline: continue
+
+               # Look for colon
+               msearch = myline.find(':')
                
                # If semicolon found assume its a new key
                # This may cause problems if : are used for key values but works for now
-               if msearch:
+               if msearch != -1:
                        # Split on the first semicolon creating two strings in the array mobjs
-                       mobjs = colon.split(mylines[pos],1)
+                       mobjs = myline.split(':', 1)
+                       mobjs[1] = mobjs[1].strip()
                        # Start a new array using the first element of mobjs
-                       newarray=[mobjs[0]]
+                       cur_array = [mobjs[0]]
                        if mobjs[1]:
                                # split on white space creating additional array elements
-                               subarray=mobjs[1].split()
-                               if len(subarray)>0:
-                                       
+                               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]