summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-06-20 22:39:50 +0000
committerZac Medico <zmedico@gentoo.org>2006-06-20 22:39:50 +0000
commit11c03b891526e89f5884f966df6e8456b9af9145 (patch)
tree78a303dd042779bbac0972161eed314f2b4051fc
parent6f77e514d00921bb526546cbda53b39ae1e3cd89 (diff)
downloadportage-11c03b891526e89f5884f966df6e8456b9af9145.tar.gz
portage-11c03b891526e89f5884f966df6e8456b9af9145.tar.bz2
portage-11c03b891526e89f5884f966df6e8456b9af9145.zip
Use get() to simplify setitem logic as suggested by Brian Harring.
svn path=/main/trunk/; revision=3546
-rw-r--r--pym/cache/metadata_overlay.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/pym/cache/metadata_overlay.py b/pym/cache/metadata_overlay.py
index 104dc34d1..821beead1 100644
--- a/pym/cache/metadata_overlay.py
+++ b/pym/cache/metadata_overlay.py
@@ -35,18 +35,16 @@ class database(template.database):
return value
def _setitem(self, name, values):
- try:
- value_ro = self.db_ro[name]
- if self._are_values_identical(value_ro,values):
- # we have matching values in the underlying db_ro
- # so it is unnecessary to store data in db_rw
- try:
- del self.db_rw[name] # delete unwanted whiteout when necessary
- except KeyError:
- pass
- return
- except KeyError:
- pass
+ value_ro = self.db_ro.get(name, None)
+ if value_ro is not None and \
+ self._are_values_identical(value_ro, values):
+ # we have matching values in the underlying db_ro
+ # so it is unnecessary to store data in db_rw
+ try:
+ del self.db_rw[name] # delete unwanted whiteout when necessary
+ except KeyError:
+ pass
+ return
self.db_rw[name] = values
def _delitem(self, cpv):