From 120058fac2436397ccfafb0202e8e12d0c9a528e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 15 Oct 2006 20:01:26 +0000 Subject: Make grabdict incremental, so that keys occuring multiple times will stack up instead of overwritting eachother. Thanks to Sven Wegener for this suggestion. svn path=/main/trunk/; revision=4718 --- pym/portage_util.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pym/portage_util.py b/pym/portage_util.py index f64169a9c..950c83197 100644 --- a/pym/portage_util.py +++ b/pym/portage_util.py @@ -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): -- cgit v1.2.3-1-g7c22