config: fix None appearing in config if the file doesn't exist close #777
This commit is contained in:
parent
9b1b9593e8
commit
972a09df41
@ -351,7 +351,7 @@ class KlipperScreenConfig:
|
|||||||
saved_def = []
|
saved_def = []
|
||||||
found_saved = False
|
found_saved = False
|
||||||
if not path.exists(config_path):
|
if not path.exists(config_path):
|
||||||
return [None, None]
|
return ["", None]
|
||||||
with open(config_path) as file:
|
with open(config_path) as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
line = line.replace('\n', '')
|
line = line.replace('\n', '')
|
||||||
@ -485,10 +485,11 @@ class KlipperScreenConfig:
|
|||||||
else:
|
else:
|
||||||
user_def, saved_def = self.separate_saved_config(self.config_path)
|
user_def, saved_def = self.separate_saved_config(self.config_path)
|
||||||
|
|
||||||
extra_lb = "\n" if saved_def is not None else ""
|
contents = (f"{user_def}\n"
|
||||||
contents = "%s\n%s%s\n%s\n%s\n%s\n" % (
|
f"{self.do_not_edit_line}\n"
|
||||||
user_def, self.do_not_edit_line, extra_lb, self.do_not_edit_prefix, "\n".join(save_output),
|
f"{self.do_not_edit_prefix}\n"
|
||||||
self.do_not_edit_prefix)
|
+ '\n'.join(save_output) + f"\n"
|
||||||
|
f"{self.do_not_edit_prefix}\n")
|
||||||
|
|
||||||
if self.config_path != self.default_config_path:
|
if self.config_path != self.default_config_path:
|
||||||
filepath = self.config_path
|
filepath = self.config_path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user