diff --git a/owrx/config.py b/owrx/config.py index 4aa1c8e..bdecd04 100644 --- a/owrx/config.py +++ b/owrx/config.py @@ -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 diff --git a/owrx/property/__init__.py b/owrx/property/__init__.py index 853cca3..f3560fa 100644 --- a/owrx/property/__init__.py +++ b/owrx/property/__init__.py @@ -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()])