Now an output can extend another output that extends ...

- Even when the other outputs aren't yet configured
- Also added an error when the types doesn't match

Closes #184
This commit is contained in:
Salvador E. Tropea 2022-04-14 10:38:07 -03:00
parent 0e8e697d19
commit 8c1d6e53c2
1 changed files with 7 additions and 2 deletions

View File

@ -93,15 +93,20 @@ class BaseOutput(RegOutput):
out = RegOutput.get_output(self.extends) out = RegOutput.get_output(self.extends)
if out is None: if out is None:
raise KiPlotConfigurationError('Unknown output `{}` in `extends`'.format(self.extends)) raise KiPlotConfigurationError('Unknown output `{}` in `extends`'.format(self.extends))
if out.type != self.type:
raise KiPlotConfigurationError('Trying to extend `{}` using another type `{}`'.format(out, self))
if not out._configured:
# Make sure the extended output is configured, so it can be an extension of another output
out.config(None)
if out._tree: if out._tree:
options = out._tree.get('options', None) options = out._tree.get('options', None)
if options: if options:
old_options = self._tree.get('options', {}) old_options = self._tree.get('options', {})
# logger.error("Old options: "+str(old_options)) # logger.error(self.name+" Old options: "+str(old_options))
options = deepcopy(options) options = deepcopy(options)
options.update(old_options) options.update(old_options)
self._tree['options'] = options self._tree['options'] = options
# logger.error("New options: "+str(options)) # logger.error(self.name+" New options: "+str(options))
super().config(parent) super().config(parent)
to_dis = self.disable_run_by_default to_dis = self.disable_run_by_default
if isinstance(to_dis, str) and to_dis: # Skip the boolean case if isinstance(to_dis, str) and to_dis: # Skip the boolean case