From cb8d54b581e8282826d4845e40a8ee93ce9730e7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 7 Jun 2024 15:39:38 +0300 Subject: [PATCH] Refactor instance Signed-off-by: Dimitris Zlatanidis --- slpkg/dialog_configs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/slpkg/dialog_configs.py b/slpkg/dialog_configs.py index 5dd09b7e..d2a7f5a9 100644 --- a/slpkg/dialog_configs.py +++ b/slpkg/dialog_configs.py @@ -21,7 +21,7 @@ class FormConfigs(Configs): self.dialogbox = DialogBox() self.errors = Errors() - self.toml_original: dict = {} + self.original_configs: dict = {} self.config_file: Path = Path(self.etc_path, f'{self.prog_name}.toml') def is_dialog_enabled(self) -> None: @@ -68,7 +68,7 @@ class FormConfigs(Configs): def read_configs(self) -> None: """Read the original config file.""" with open(self.config_file, 'r', encoding='utf-8') as file: - self.toml_original: dict = tomlkit.parse(file.read()) + self.original_configs: dict = tomlkit.parse(file.read()) def write_configs(self, tags: list) -> None: """Write new configs to the file. @@ -78,7 +78,7 @@ class FormConfigs(Configs): """ self.read_configs() - for key, new in zip(self.toml_original['CONFIGS'].keys(), tags): + for key, new in zip(self.original_configs['CONFIGS'].keys(), tags): digit_pattern = re.compile(r"^-?\d+(\.\d+)?$") # pattern for int and float numbers. list_pattern = re.compile(r'^\s*\[.*\]\s*$') # pattern for list. @@ -94,7 +94,7 @@ class FormConfigs(Configs): elif list_pattern.match(new): new = ast.literal_eval(new) - self.toml_original['CONFIGS'][key] = new + self.original_configs['CONFIGS'][key] = new with open(self.config_file, 'w', encoding='utf-8') as file: - file.write(tomlkit.dumps(self.toml_original)) + file.write(tomlkit.dumps(self.original_configs))