Set non-existing config entries if requested with a default value, and create ~/.openlp when saving config file.

bzr-revno: 228
This commit is contained in:
Michael Gorven 2008-12-15 21:14:26 +00:00
parent 63bb9b3186
commit 2ae661b64b
2 changed files with 6 additions and 0 deletions

View File

@ -42,10 +42,13 @@ class ConfigHelper(object):
@staticmethod
def get_config(section, key, default=None):
print "Requesting %s/%s default %s" % (section, key, default)
reg = ConfigHelper.get_registry()
if reg.has_value(section, key):
return reg.get_value(section, key, default)
else:
if default is not None:
ConfigHelper.set_config(section, key, default)
return default
@staticmethod

View File

@ -97,6 +97,9 @@ class LinRegistry(Registry):
def _save(self):
try:
if not os.path.exists(os.path.dirname(self.file_name)):
os.makedirs(os.path.dirname(self.file_name))
file_handle = open(self.file_name, 'w')
self.config.write(file_handle)
close(file_handle)