Skip to content
This repository was archived by the owner on Jun 5, 2023. It is now read-only.

Commit 9fc402b

Browse files
committed
fix crash if config file does not exist
1 parent e64bc6a commit 9fc402b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Jade/Settings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import configparser
22
import os
33
import pathlib
4+
from Jade import Utils
45

56

67
class Options():
78
def __init__(self):
89
self.config = configparser.ConfigParser()
910
self.config.optionxform = str
10-
self.settings = f"{str(pathlib.Path.home())}/.config/jade/desktop.conf"
11-
self.config.read(self.settings)
11+
self.config_file = f"{str(pathlib.Path.home())}/.config/jade/desktop.conf"
12+
self.config.read(self.config_file)
1213

1314
def save(self, key, value):
1415
self.config.set('DEFAULT', f'{key}', f'{value}')
15-
with open(self.settings, 'w') as file:
16-
self.config.write(file)
16+
with open(self.config_file, 'w+') as f:
17+
self.config.write(f)
1718

1819
def load(self):
1920
defaults = {
@@ -36,7 +37,7 @@ def load(self):
3637
"workspace4": "",
3738
"tourDone": False
3839
}
39-
if os.path.exists(self.settings):
40+
if os.path.exists(self.config_file):
4041
for key, value in self.config.items('DEFAULT'):
4142
if value == "true" or value == "false":
4243
defaults[key] = self.config.getboolean('DEFAULT', key)

0 commit comments

Comments
 (0)