Merge branch 'warn_invalid_config' of https://github.com/Luflosi/kitty
This commit is contained in:
commit
4b08ce2a09
@ -60,29 +60,31 @@ def parse_line(line, type_map, special_handling, ans, all_keys, base_path_for_in
|
|||||||
if not line or line.startswith('#'):
|
if not line or line.startswith('#'):
|
||||||
return
|
return
|
||||||
m = key_pat.match(line)
|
m = key_pat.match(line)
|
||||||
if m is not None:
|
if m is None:
|
||||||
key, val = m.groups()
|
log_error('Ignoring invalid config line: {}'.format(line))
|
||||||
if special_handling(key, val, ans):
|
return
|
||||||
return
|
key, val = m.groups()
|
||||||
if key == 'include':
|
if special_handling(key, val, ans):
|
||||||
val = os.path.expandvars(os.path.expanduser(val.strip()))
|
return
|
||||||
if not os.path.isabs(val):
|
if key == 'include':
|
||||||
val = os.path.join(base_path_for_includes, val)
|
val = os.path.expandvars(os.path.expanduser(val.strip()))
|
||||||
try:
|
if not os.path.isabs(val):
|
||||||
with open(val, encoding='utf-8', errors='replace') as include:
|
val = os.path.join(base_path_for_includes, val)
|
||||||
_parse(include, type_map, special_handling, ans, all_keys)
|
try:
|
||||||
except FileNotFoundError:
|
with open(val, encoding='utf-8', errors='replace') as include:
|
||||||
log_error('Could not find included config file: {}, ignoring'.format(val))
|
_parse(include, type_map, special_handling, ans, all_keys)
|
||||||
except EnvironmentError:
|
except FileNotFoundError:
|
||||||
log_error('Could not read from included config file: {}, ignoring'.format(val))
|
log_error('Could not find included config file: {}, ignoring'.format(val))
|
||||||
return
|
except EnvironmentError:
|
||||||
if all_keys is not None and key not in all_keys:
|
log_error('Could not read from included config file: {}, ignoring'.format(val))
|
||||||
log_error('Ignoring unknown config key: {}'.format(key))
|
return
|
||||||
return
|
if all_keys is not None and key not in all_keys:
|
||||||
tm = type_map.get(key)
|
log_error('Ignoring unknown config key: {}'.format(key))
|
||||||
if tm is not None:
|
return
|
||||||
val = tm(val)
|
tm = type_map.get(key)
|
||||||
ans[key] = val
|
if tm is not None:
|
||||||
|
val = tm(val)
|
||||||
|
ans[key] = val
|
||||||
|
|
||||||
|
|
||||||
def _parse(lines, type_map, special_handling, ans, all_keys):
|
def _parse(lines, type_map, special_handling, ans, all_keys):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user