Use get() to simplify setitem logic as suggested by Brian Harring. This patch is... v2.1-r1
authorZac Medico <zmedico@gentoo.org>
Wed, 21 Jun 2006 04:16:29 +0000 (04:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 21 Jun 2006 04:16:29 +0000 (04:16 -0000)
svn path=/main/branches/2.1/; revision=3581

pym/cache/metadata_overlay.py

index b12740bdb16de52b3638e11aa26e7c8f0952ecad..287e05521ca4734c53447bb18717aa436df9f596 100644 (file)
@@ -36,18 +36,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):