Use get() to simplify setitem logic as suggested by Brian Harring.
authorZac Medico <zmedico@gentoo.org>
Tue, 20 Jun 2006 22:39:50 +0000 (22:39 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 20 Jun 2006 22:39:50 +0000 (22:39 -0000)
svn path=/main/trunk/; revision=3546

pym/cache/metadata_overlay.py

index 104dc34d1556753f9e467cebb1cc893b861d1864..821beead177695ead27c9888f4d998cd8b3a5503 100644 (file)
@@ -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):