From deef6c41c2419ec4919075cbf6e8b5a468f72612 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 21 Jun 2006 04:16:29 +0000 Subject: [PATCH] Use get() to simplify setitem logic as suggested by Brian Harring. This patch is from trunk r3546. svn path=/main/branches/2.1/; revision=3581 --- pym/cache/metadata_overlay.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pym/cache/metadata_overlay.py b/pym/cache/metadata_overlay.py index b12740bdb..287e05521 100644 --- a/pym/cache/metadata_overlay.py +++ b/pym/cache/metadata_overlay.py @@ -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): -- 2.26.2