- def set_and_check_for_change(self, key: str, value: _DbType) -> bool:
- 'To attribute of key set value, reply if that changed anything.'
- self._typecheck(key, value)
- old_value = getattr(self, key)
- setattr(self, key, value)
- return value != old_value
+ def _set_and_check_for_dict(self, update: _Update) -> bool:
+ d = getattr(self, update.path)
+ if update.value is None:
+ if update.arg == '':
+ d.clear()
+ else:
+ del d[update.arg]
+ return True
+ old_value = d.get(update.arg, None)
+ d[update.arg] = update.value
+ return update.value != old_value
+
+ def set_and_check_for_change(self, update: _Update) -> bool:
+ 'Apply update, return if that actually made a difference.'
+ self._typecheck(update.path, update.value)
+ old_value = getattr(self, update.path)
+ setattr(self, update.path, update.value)
+ return update.value != old_value