summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-15 20:01:26 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-15 20:01:26 +0000
commit120058fac2436397ccfafb0202e8e12d0c9a528e (patch)
tree6d37273a7117f841122ddc26b7238eaf302e6e29
parentdc43c514fa44d1cbfa978b635e44164f467be69f (diff)
downloadportage-120058fac2436397ccfafb0202e8e12d0c9a528e.tar.gz
portage-120058fac2436397ccfafb0202e8e12d0c9a528e.tar.bz2
portage-120058fac2436397ccfafb0202e8e12d0c9a528e.zip
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
-rw-r--r--pym/portage_util.py13
1 files 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):