🔨 Improve config.ini parser

This commit is contained in:
Scott Lahteine 2023-01-11 01:19:45 -06:00
parent fe62c8006a
commit 5af5c2a35c

View file

@ -180,10 +180,11 @@ def apply_config_ini(cp):
# For a key ending in .ini load and parse another .ini file # For a key ending in .ini load and parse another .ini file
if ckey.endswith('.ini'): if ckey.endswith('.ini'):
sect = 'base' sect = 'base'
if '@' in ckey: sect, ckey = ckey.split('@') if '@' in ckey: sect, ckey = map(str.strip, ckey.split('@'))
other_ini = configparser.ConfigParser() cp2 = configparser.ConfigParser()
other_ini.read(config_path(ckey)) cp2.read(config_path(ckey))
apply_sections(other_ini, sect) apply_sections(cp2, sect)
ckey = 'base';
# (Allow 'example/' as a shortcut for 'examples/') # (Allow 'example/' as a shortcut for 'examples/')
elif ckey.startswith('example/'): elif ckey.startswith('example/'):
@ -191,11 +192,11 @@ def apply_config_ini(cp):
# For 'examples/<path>' fetch an example set from GitHub. # For 'examples/<path>' fetch an example set from GitHub.
# For https?:// do a direct fetch of the URL. # For https?:// do a direct fetch of the URL.
elif ckey.startswith('examples/') or ckey.startswith('http'): if ckey.startswith('examples/') or ckey.startswith('http:'):
fetch_example(ckey) fetch_example(ckey)
ckey = 'base' ckey = 'base'
elif ckey == 'all': if ckey == 'all':
apply_sections(cp) apply_sections(cp)
else: else: