summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-15 20:32:09 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-15 20:32:09 +0000
commitc93b12798f3a605a7006b777a094170d580427ea (patch)
tree6c9bbe7eb81784e583d402dfe27ce57e303cb65b
parent120058fac2436397ccfafb0202e8e12d0c9a528e (diff)
downloadportage-c93b12798f3a605a7006b777a094170d580427ea.tar.gz
portage-c93b12798f3a605a7006b777a094170d580427ea.tar.bz2
portage-c93b12798f3a605a7006b777a094170d580427ea.zip
Simplify and optimize grabdict. Thanks to Brian Harring for suggesting this.
svn path=/main/trunk/; revision=4719
-rw-r--r--pym/portage_util.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py
index 950c83197..995688d03 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -157,17 +157,13 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
continue
if len(myline) < 1 and empty == 1:
continue
- if juststrings:
- if incremental and newdict.get(myline[0], None):
- newdict[myline[0]] = \
- newdict[myline[0]] + " " + " ".join(myline[1:]))
- else:
- newdict[myline[0]] = " ".join(myline[1:])
+ if incremental:
+ newdict.setdefault(myline[0], []).extend(myline[1:])
else:
- if incremental and newdict.get(myline[0], None):
- newdict[myline[0]] = newdict[myline[0]] + myline[1:])
- else:
- newdict[myline[0]] = myline[1:]
+ newdict[myline[0]] = myline[1:]
+ if juststrings:
+ for k, v in newdict.iteritems():
+ newdict[k] = " ".join(v)
return newdict
def grabdict_package(myfilename, juststrings=0, recursive=0):