forked from openlp/openlp
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:
parent
63bb9b3186
commit
2ae661b64b
@ -42,10 +42,13 @@ class ConfigHelper(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config(section, key, default=None):
|
def get_config(section, key, default=None):
|
||||||
|
print "Requesting %s/%s default %s" % (section, key, default)
|
||||||
reg = ConfigHelper.get_registry()
|
reg = ConfigHelper.get_registry()
|
||||||
if reg.has_value(section, key):
|
if reg.has_value(section, key):
|
||||||
return reg.get_value(section, key, default)
|
return reg.get_value(section, key, default)
|
||||||
else:
|
else:
|
||||||
|
if default is not None:
|
||||||
|
ConfigHelper.set_config(section, key, default)
|
||||||
return default
|
return default
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -97,6 +97,9 @@ class LinRegistry(Registry):
|
|||||||
|
|
||||||
def _save(self):
|
def _save(self):
|
||||||
try:
|
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')
|
file_handle = open(self.file_name, 'w')
|
||||||
self.config.write(file_handle)
|
self.config.write(file_handle)
|
||||||
close(file_handle)
|
close(file_handle)
|
||||||
|
Loading…
Reference in New Issue
Block a user