diff --git a/src/backend/rule_manager.py b/src/backend/rule_manager.py index 984988f..0576283 100644 --- a/src/backend/rule_manager.py +++ b/src/backend/rule_manager.py @@ -6,7 +6,8 @@ from src.config.config_manager import ConfigManager from src.widgets.widget_base_tile import BaseTile from src.logger import BroadErrorHandler - +import logging +logger = logging.getLogger(__name__) RuleConfig = Dict[str, List[str]] @@ -20,9 +21,10 @@ def __init__(self): def _loadRuleFile(self, filename_base): if not self._loadedRules: filename = f"{filename_base}.rules" - data_path = Path(ConfigManager.config()["data_path"]) + data_path = ConfigManager.config()["data_path"] if not data_path: raise ValueError("No editor directory path known") + data_path = Path(data_path) automapper_path = data_path.joinpath(Path("editor/automap")) if not automapper_path.exists(): @@ -40,13 +42,17 @@ def _loadRuleFile(self, filename_base): self._header = [] self._loadedRules = True - @BroadErrorHandler + @BroadErrorHandler(logger) def loadRules(self, filename): if not self._loadedRules: filename = RuleManager._getFileBase(filename) - self._loadRuleFile(filename) + try: + self._loadRuleFile(filename) + except ValueError: + return False + return True - @BroadErrorHandler + @BroadErrorHandler(logger) def saveRule(self, filename, rule_name): filename = RuleManager._getFileBase(filename) if not self._loadedRules: @@ -57,7 +63,7 @@ def saveRule(self, filename, rule_name): def getRules(self) -> List[str]: if not self._loadedRules: - raise ValueError("Rules are not loaded yet") + return [] return list(self._config.keys()) @staticmethod diff --git a/src/config/config_manager.py b/src/config/config_manager.py index 873e4bf..c8b91e8 100644 --- a/src/config/config_manager.py +++ b/src/config/config_manager.py @@ -43,8 +43,8 @@ def _checkConfig(self) -> bool: return updated def createConfig(self): - client_path = "" - data_path = "" + client_path = None + data_path = None # noinspection PyBroadException try: client_path = StorageFinder.instance().getClientPath() diff --git a/src/widgets/widget_mapper_generator.py b/src/widgets/widget_mapper_generator.py index eeef059..be54ab2 100644 --- a/src/widgets/widget_mapper_generator.py +++ b/src/widgets/widget_mapper_generator.py @@ -12,6 +12,8 @@ from src.config.config_manager import ConfigManager from src.backend.map_generator import MapGenerator from src.logger import BroadErrorHandler +import logging +logger = logging.getLogger(__name__) class MapperGeneratorWidget(QWidget): @@ -135,7 +137,7 @@ def ruleNameToggle(self): self.existing_mapper.show() self._updateGenerateButton() - @BroadErrorHandler + @BroadErrorHandler(logger) def startDDNetCheck(self): # TODO # generate Map