also populate lists with defaults in config
This commit is contained in:
parent
d5da33feb7
commit
9a288e8893
1 changed files with 19 additions and 9 deletions
|
@ -68,7 +68,8 @@ def load_config():
|
|||
#add missing defaults
|
||||
for section in (
|
||||
'capabilities', 'cantPlay', 'itemName', 'media', 'posters',
|
||||
'site', 'tv', 'user.ui', 'user.ui.part', 'user.ui.showFolder'
|
||||
'site', 'tv', 'user.ui', 'user.ui.part', 'user.ui.showFolder',
|
||||
'menuExtras'
|
||||
):
|
||||
parts = map(lambda p: p.replace('\0', '\\.'), section.replace('\\.', '\0').split('.'))
|
||||
#print 'checking', section
|
||||
|
@ -76,10 +77,19 @@ def load_config():
|
|||
d = default
|
||||
while len(parts):
|
||||
part = parts.pop(0)
|
||||
d = d[part]
|
||||
if part not in c:
|
||||
if isinstance(d, list):
|
||||
c[part] = []
|
||||
else:
|
||||
c[part] = {}
|
||||
c = c[part]
|
||||
d = d[part]
|
||||
if isinstance(d, list):
|
||||
if not c:
|
||||
c += d
|
||||
sys.stderr.write("adding default value for %s = %s\n" % (
|
||||
section, str(d)))
|
||||
else:
|
||||
for key in d:
|
||||
if key not in c:
|
||||
sys.stderr.write("adding default value for %s.%s = %s\n" % (
|
||||
|
|
Loading…
Reference in a new issue