From 972a09df4156faa24ffc44e530901e63a15cab42 Mon Sep 17 00:00:00 2001 From: alfrix Date: Wed, 16 Nov 2022 21:10:57 -0300 Subject: [PATCH] config: fix None appearing in config if the file doesn't exist close #777 --- ks_includes/config.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ks_includes/config.py b/ks_includes/config.py index 253dbd17..09524350 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -351,7 +351,7 @@ class KlipperScreenConfig: saved_def = [] found_saved = False if not path.exists(config_path): - return [None, None] + return ["", None] with open(config_path) as file: for line in file: line = line.replace('\n', '') @@ -485,10 +485,11 @@ class KlipperScreenConfig: else: user_def, saved_def = self.separate_saved_config(self.config_path) - extra_lb = "\n" if saved_def is not None else "" - contents = "%s\n%s%s\n%s\n%s\n%s\n" % ( - user_def, self.do_not_edit_line, extra_lb, self.do_not_edit_prefix, "\n".join(save_output), - self.do_not_edit_prefix) + contents = (f"{user_def}\n" + f"{self.do_not_edit_line}\n" + f"{self.do_not_edit_prefix}\n" + + '\n'.join(save_output) + f"\n" + f"{self.do_not_edit_prefix}\n") if self.config_path != self.default_config_path: filepath = self.config_path