From 8c1d6e53c205557c2d918adca02b3f002e947c3d Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 14 Apr 2022 10:38:07 -0300 Subject: [PATCH] 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 --- kibot/out_base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kibot/out_base.py b/kibot/out_base.py index cd8c706f..1023f2c9 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -93,15 +93,20 @@ class BaseOutput(RegOutput): out = RegOutput.get_output(self.extends) if out is None: 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: options = out._tree.get('options', None) if 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.update(old_options) self._tree['options'] = options - # logger.error("New options: "+str(options)) + # logger.error(self.name+" New options: "+str(options)) super().config(parent) to_dis = self.disable_run_by_default if isinstance(to_dis, str) and to_dis: # Skip the boolean case