Added correct detection for unknown outputs/groups inside groups

This commit is contained in:
Salvador E. Tropea 2023-01-05 08:37:55 -03:00
parent 1202351fed
commit 745e8758ad
2 changed files with 9 additions and 3 deletions

View File

@ -438,7 +438,10 @@ def _generate_outputs(outputs, targets, invert, skip_pre, cli_order, no_priority
exit(EXIT_BAD_ARGS) exit(EXIT_BAD_ARGS)
# Expand groups # Expand groups
logger.debug('Outputs before groups expansion: {}'.format(targets)) logger.debug('Outputs before groups expansion: {}'.format(targets))
targets = RegOutput.solve_groups(targets) try:
targets = RegOutput.solve_groups(targets, 'command line')
except KiPlotConfigurationError as e:
config_error(str(e))
logger.debug('Outputs after groups expansion: {}'.format(targets)) logger.debug('Outputs after groups expansion: {}'.format(targets))
# Now convert the list of names into a list of output objects # Now convert the list of names into a list of output objects
if cli_order: if cli_order:

View File

@ -164,7 +164,7 @@ class RegOutput(Optionable, Registrable):
return None return None
@staticmethod @staticmethod
def solve_groups(targets, level=0): def solve_groups(targets, where, level=0):
""" Replaces any group by its members. """ Replaces any group by its members.
Returns a new list. Returns a new list.
Assumes the outputs and groups are valid. """ Assumes the outputs and groups are valid. """
@ -177,8 +177,11 @@ class RegOutput(Optionable, Registrable):
if t in RegOutput._def_outputs: if t in RegOutput._def_outputs:
new_targets.append(t) new_targets.append(t)
else: else:
new_grp = RegOutput._def_groups.get(t, None)
if new_grp is None:
raise KiPlotConfigurationError('Unknown output/group `{}` (in `{}`)'.format(t, where))
# Recursive expand # Recursive expand
new_targets.extend(RegOutput.solve_groups(RegOutput._def_groups[t], level)) new_targets.extend(RegOutput.solve_groups(new_grp, t, level))
return new_targets return new_targets