include changed wsjt keys in config migration

This commit is contained in:
Jakob Ketterl 2020-05-14 22:56:49 +02:00
parent e557d46c0d
commit 048aab682f
2 changed files with 24 additions and 0 deletions

View File

@ -26,6 +26,11 @@ class ConfigMigrator(ABC):
def migrate(self, config):
pass
def renameKey(self, config, old, new):
if old in config and not new in config:
config[new] = config[old]
del config[old]
class ConfigMigratorVersion1(ConfigMigrator):
def migrate(self, config):
@ -37,6 +42,9 @@ class ConfigMigratorVersion1(ConfigMigrator):
levels = config["waterfall_auto_level_margin"]
config["waterfall_auto_level_margin"] = {"min": levels[0], "max": levels[1]}
self.renameKey(config, "wsjt_queue_workers", "decoding_queue_workers")
self.renameKey(config, "wsjt_queue_length", "decoding_queue_length")
config["version"] = 2
return config

View File

@ -40,6 +40,10 @@ class PropertyManager(ABC):
def __dict__(self):
pass
@abstractmethod
def __delitem__(self, key):
pass
@abstractmethod
def keys(self):
pass
@ -98,6 +102,9 @@ class PropertyLayer(PropertyManager):
def __dict__(self):
return {k: v for k, v in self.properties.items()}
def __delitem__(self, key):
return self.properties.__delitem__(key)
def keys(self):
return self.properties.keys()
@ -132,6 +139,11 @@ class PropertyFilter(PropertyManager):
def __dict__(self):
return {k: v for k, v in self.pm.__dict__().items() if k in self.props}
def __delitem__(self, key):
if key not in self.props:
raise KeyError(key)
return self.pm.__delitem__(key)
def keys(self):
return [k for k in self.pm.keys() if k in self.props]
@ -226,5 +238,9 @@ class PropertyStack(PropertyManager):
def __dict__(self):
return {k: self.__getitem__(k) for k in self.keys()}
def __delitem__(self, key):
for layer in self.layers:
layer["props"].__delitem__(key)
def keys(self):
return set([key for l in self.layers for key in l["props"].keys()])