Make sure that check_group actually tests presense of some group

It was not much useful actually: e.g. it skipped the fact that warning:regular
highlight group was not defined.
This commit is contained in:
Foo 2015-03-01 13:51:22 +03:00
parent d797a25fa8
commit 2d9e759f41

View File

@ -173,41 +173,47 @@ def check_group(group, data, context, echoerr):
return True, False, False return True, False, False
colorscheme = data['colorscheme'] colorscheme = data['colorscheme']
ext = data['ext'] ext = data['ext']
configs = [] configs = None
if ext: if ext:
def listed_key(d, k):
try:
return [d[k]]
except KeyError:
return []
if colorscheme == '__main__': if colorscheme == '__main__':
configs.append([config for config in data['ext_colorscheme_configs'][ext].items()]) colorscheme_names = set(data['ext_colorscheme_configs'][ext])
configs.append([config for config in data['top_colorscheme_configs'].items()]) colorscheme_names.update(data['top_colorscheme_configs'])
colorscheme_names.discard('__main__')
configs = [
(
name,
listed_key(data['ext_colorscheme_configs'][ext], name)
+ listed_key(data['ext_colorscheme_configs'][ext], '__main__')
+ listed_key(data['top_colorscheme_configs'], name)
)
for name in colorscheme_names
]
else: else:
try: configs = [
configs.append([data['ext_colorscheme_configs'][ext][colorscheme]]) (
except KeyError: colorscheme,
pass listed_key(data['ext_colorscheme_configs'][ext], colorscheme)
try: + listed_key(data['ext_colorscheme_configs'][ext], '__main__')
configs.append([data['ext_colorscheme_configs'][ext]['__main__']]) + listed_key(data['top_colorscheme_configs'], colorscheme)
except KeyError: )
pass ]
try:
configs.append([data['top_colorscheme_configs'][colorscheme]])
except KeyError:
pass
else: else:
try: try:
configs.append([data['top_colorscheme_configs'][colorscheme]]) configs = [(colorscheme, [data['top_colorscheme_configs'][colorscheme]])]
except KeyError: except KeyError:
pass pass
new_echoerr = DelayedEchoErr(echoerr)
hadproblem = False hadproblem = False
for config_lst in configs: for new_colorscheme, config_lst in configs:
tofind = len(config_lst)
not_found = [] not_found = []
new_data = data.copy()
new_data['colorscheme'] = new_colorscheme
for config in config_lst: for config in config_lst:
if isinstance(config, tuple):
new_colorscheme, config = config
new_data = data.copy()
new_data['colorscheme'] = new_colorscheme
else:
new_data = data
havemarks(config) havemarks(config)
try: try:
group_data = config['groups'][group] group_data = config['groups'][group]
@ -222,21 +228,17 @@ def check_group(group, data, context, echoerr):
) )
if chadproblem: if chadproblem:
hadproblem = True hadproblem = True
else:
tofind -= 1
if not tofind:
return proceed, echo, hadproblem
if not proceed: if not proceed:
break break
if not_found: if not_found and len(not_found) == len(config_lst):
new_echoerr( echoerr(
context='Error while checking group definition in colorscheme (key {key})'.format( context='Error while checking group definition in colorscheme (key {key})'.format(
key=context.key), key=context.key),
problem='name {0} is not present in {1} {2} colorschemes: {3}'.format( problem='name {0} is not present anywhere in {1} {2} {3} colorschemes: {4}'.format(
group, tofind, ext, ', '.join(not_found)), group, len(not_found), ext, new_colorscheme, ', '.join(not_found)),
problem_mark=group.mark problem_mark=group.mark
) )
new_echoerr.echo_all() hadproblem = True
return True, False, hadproblem return True, False, hadproblem