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

Commit

Permalink
fix crash if config file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
codesardine committed Oct 30, 2020
1 parent e64bc6a commit 9fc402b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Jade/Settings.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import configparser
import os
import pathlib
from Jade import Utils


class Options():
def __init__(self):
self.config = configparser.ConfigParser()
self.config.optionxform = str
self.settings = f"{str(pathlib.Path.home())}/.config/jade/desktop.conf"
self.config.read(self.settings)
self.config_file = f"{str(pathlib.Path.home())}/.config/jade/desktop.conf"
self.config.read(self.config_file)

def save(self, key, value):
self.config.set('DEFAULT', f'{key}', f'{value}')
with open(self.settings, 'w') as file:
self.config.write(file)
with open(self.config_file, 'w+') as f:
self.config.write(f)

def load(self):
defaults = {
Expand All @@ -36,7 +37,7 @@ def load(self):
"workspace4": "",
"tourDone": False
}
if os.path.exists(self.settings):
if os.path.exists(self.config_file):
for key, value in self.config.items('DEFAULT'):
if value == "true" or value == "false":
defaults[key] = self.config.getboolean('DEFAULT', key)
Expand Down

0 comments on commit 9fc402b

Please sign in to comment.