Config() now loads in defaults if no file is specified

This commit is contained in:
2010-01-30 10:00:12 +00:00
parent f79b771a38
commit d6a3a2878e

View File

@@ -6,7 +6,7 @@ def defaults():
Creates a ConfigParser instance and fills it with the default settings
"""
config = ConfigParser.ConfigParser()
config = ConfigParser.RawConfigParser()
config.add_section('main')
config.set('main', 'target_path', '/media/%(showname)s/Season %(seasonnum)s/')
@@ -28,8 +28,10 @@ class Config(dict):
if cfile:
self.load(cfile)
else:
self.defaults()
def load(self, cfile):
def load(self, cfile=None, cparser=None):
"""
Parses the TVOrganiser style config file and produces a dict
with all the elements contained within.
@@ -37,6 +39,9 @@ class Config(dict):
Also, all regex specified in the file are compiled
"""
if cparser:
configpsr = cparser
else:
configpsr = ConfigParser.RawConfigParser()
configpsr.read(cfile)
@@ -60,3 +65,8 @@ class Config(dict):
self['regex'] = regex
def defaults(self):
"""
Load default settings
"""
self.load(cparser=defaults())