def upgrade(self, storage): config = load_config_from_storage(storage) if config["format"] == self.target: return False if config["format"] not in self.upgraders: raise UserError("cannot migrate from version " + config["format"] + " to version " + self.target) while config["format"] != self.target: self.upgraders[config["format"]](storage, config) save_config_to_storage(storage, config) return True
def storage_with_config(config): storage = MemStorage("testing") save_config_to_storage(storage, config) return storage