Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparing config was fixed. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions kazam/backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class KazamConfig(ConfigParser):
CONFIGFILE = os.path.join(CONFIGDIR, "kazam.conf")

def __init__(self):
ConfigParser.__init__(self, self.DEFAULTS[0]['keys'])
super().__init__(self)
if not os.path.isdir(self.CONFIGDIR):
os.makedirs(self.CONFIGDIR)
if not os.path.isfile(self.CONFIGFILE):
Expand All @@ -98,9 +98,9 @@ def find_default(self, section, key):
if d_key == key:
return d_section["keys"][key]

def get(self, section, key):
def get(self, section, key, **kwargs):
try:
return ConfigParser.get(self, section, key)
return super().get(section, key, **kwargs)
except NoSectionError:
default = self.find_default(section, key)
self.set(section, key, default)
Expand All @@ -120,11 +120,7 @@ def getboolean(self, section, key):
return False

def set(self, section, option, value):
# If the section referred to doesn't exist (rare case),
# then create it
if not self.has_section(section):
self.add_section(section)
ConfigParser.set(self, section, option, str(value))
super().set(section, option, str(value))

def write(self):
file_ = open(self.CONFIGFILE, "w")
Expand Down