Make grabdict incremental, so that keys occuring multiple times will stack up instead...
authorZac Medico <zmedico@gentoo.org>
Sun, 15 Oct 2006 20:01:26 +0000 (20:01 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 15 Oct 2006 20:01:26 +0000 (20:01 -0000)
svn path=/main/trunk/; revision=4718

pym/portage_util.py

index f64169a9cc6d3670dc5b26673b5c2cd394322644..950c83197e518b9cec5aed4a675b67e081754295 100644 (file)
@@ -144,7 +144,7 @@ def stack_lists(lists, incremental=1):
                                new_list[y] = True
        return new_list.keys()
 
-def grabdict(myfilename, juststrings=0, empty=0, recursive=0):
+def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
        """This function grabs the lines in a file, normalizes whitespace and returns lines in a dictionary"""
        newdict={}
        for x in grablines(myfilename, recursive):
@@ -158,9 +158,16 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0):
                if len(myline) < 1 and empty == 1:
                        continue
                if juststrings:
-                       newdict[myline[0]]=string.join(myline[1:])
+                       if incremental and newdict.get(myline[0], None):
+                               newdict[myline[0]] = \
+                                       newdict[myline[0]] + " " +  " ".join(myline[1:]))
+                       else:
+                               newdict[myline[0]] = " ".join(myline[1:])
                else:
-                       newdict[myline[0]]=myline[1:]
+                       if incremental and newdict.get(myline[0], None):
+                               newdict[myline[0]] = newdict[myline[0]] + myline[1:])
+                       else:
+                               newdict[myline[0]] = myline[1:]
        return newdict
 
 def grabdict_package(myfilename, juststrings=0, recursive=0):