From 318f0993bf6fdeb3a2c88bb1ed133864298a2832 Mon Sep 17 00:00:00 2001 From: Diego Capusotto Date: Tue, 14 Dec 2021 20:44:37 -0300 Subject: [PATCH] Now `disable_run_by_default` can be defined as true - To avoid repeating the name of the parent output - Related to #121 --- README.md | 154 +++++++++++--------- kibot/config_reader.py | 12 +- kibot/macros.py | 11 +- kibot/optionable.py | 39 +++-- kibot/out_base.py | 9 +- tests/test_plot/test_yaml_errors.py | 10 +- tests/yaml_samples/import_test_4.kibot.yaml | 2 +- 7 files changed, 138 insertions(+), 99 deletions(-) diff --git a/README.md b/README.md index ee857690..7a57ad2b 100644 --- a/README.md +++ b/README.md @@ -719,9 +719,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `boardview` output. * Valid keys: @@ -741,9 +742,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `bom` output. * Valid keys: @@ -883,9 +885,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `compress` output. * Valid keys: @@ -912,9 +915,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user] List of PCB layers to plot. * Valid keys: @@ -961,9 +965,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `excellon` output. * Valid keys: @@ -999,9 +1004,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `gerb_drill` output. * Valid keys: @@ -1028,9 +1034,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user] List of PCB layers to plot. * Valid keys: @@ -1082,9 +1089,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user] List of PCB layers to plot. * Valid keys: @@ -1133,9 +1141,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `ibom` output. * Valid keys: @@ -1200,9 +1209,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `kibom` output. * Valid keys: @@ -1296,9 +1306,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `kicost` output. * Valid keys: @@ -1338,9 +1349,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `pcbdraw` output. * Valid keys: @@ -1389,15 +1401,16 @@ Next time you need this list just use an alias, like this: Use ${filename(LAYER)} for the file corresponding to LAYER. - `output`: [string='Custom_report.txt'] File name for the custom report. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. - `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. - `drill_marks`: [string='full'] what to use to indicate the drill places, can be none, small or full (for real scale). - `edge_cut_extension`: [string=''] Used to configure the edge cuts layer extension for Protel mode. Include the dot. - `exclude_edge_layer`: [boolean=true] Do not include the PCB edge layer. - `exclude_pads_from_silkscreen`: [boolean=false] Do not plot the component pads in the silk screen (KiCad 5.x only). - - `extends`: [string=''] Copy the options from the indicated output. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `force_plot_invisible_refs_vals`: [boolean=false] Include references and values even when they are marked as invisible. - `inner_extension_pattern`: [string=''] Used to change the Protel style extensions for inner layers. The replacement pattern can contain %n for the inner layer number and %N for the layer number. @@ -1454,9 +1467,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user] List of PCB layers to include in the PDF. * Valid keys: @@ -1491,9 +1505,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `pdf_sch_print` output. * Valid keys: @@ -1514,9 +1529,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `position` output. * Valid keys: @@ -1544,9 +1560,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user] List of PCB layers to plot. * Valid keys: @@ -1597,9 +1614,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `render_3d` output. * Valid keys: @@ -1645,9 +1663,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `sch_variant` output. * Valid keys: @@ -1665,9 +1684,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `step` output. * Valid keys: @@ -1694,9 +1714,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user] List of PCB layers to plot. * Valid keys: @@ -1741,9 +1762,10 @@ Next time you need this list just use an alias, like this: * Valid keys: - `comment`: [string=''] A comment for documentation purposes. - `dir`: [string='./'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir. - - `disable_run_by_default`: [string=''] Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original.. - - `extends`: [string=''] Copy the options from the indicated output. + - `disable_run_by_default`: [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending. + - `extends`: [string=''] Copy the `options` section from the indicated output. - `name`: [string=''] Used to identify this particular output definition. - `options`: [dict] Options for the `svg_sch_print` output. * Valid keys: diff --git a/kibot/config_reader.py b/kibot/config_reader.py index 632be412..a6ecbfa9 100644 --- a/kibot/config_reader.py +++ b/kibot/config_reader.py @@ -93,11 +93,15 @@ class CfgYamlReader(object): o_out.run_by_default = True o_out.disable_run_by_default = o_tree.get('disable_run_by_default', '') # Pre-parse the disable_run_by_default option - if not isinstance(o_out.disable_run_by_default, str): + if isinstance(o_out.disable_run_by_default, str): + if o_out.disable_run_by_default: + self.no_run_by_default.append(o_out.disable_run_by_default) + elif isinstance(o_out.disable_run_by_default, bool): + # True means to disable the one we extend + if o_out.disable_run_by_default and o_out.extends: + self.no_run_by_default.append(o_out.extends) + else: o_out.disable_run_by_default = '' - elif o_out.disable_run_by_default: - self.no_run_by_default.append(o_out.disable_run_by_default) - return o_out def _parse_outputs(self, v): diff --git a/kibot/macros.py b/kibot/macros.py index 2b8907d2..97b312fc 100644 --- a/kibot/macros.py +++ b/kibot/macros.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2020 Salvador E. Tropea -# Copyright (c) 2020 Instituto Nacional de TecnologĂ­a Industrial +# Copyright (c) 2020-2021 Salvador E. Tropea +# Copyright (c) 2020-2021 Instituto Nacional de TecnologĂ­a Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) """ @@ -76,7 +76,12 @@ def document(sentences, **kw): target = Name(id=doc_id, ctx=Store()) # Reuse the s.value Str help_str = s.value - help_str.s = type_hint+s.value.s.rstrip()+post_hint + doc_str = s.value.s.rstrip() + if type_hint and (doc_str.startswith(' [string') or doc_str.startswith(' [number') or + doc_str.startswith(' [boolean')): + # Hardcoded type hint, don't add one + type_hint = '' + help_str.s = type_hint+doc_str+post_hint sentences[n] = Assign(targets=[target], value=help_str) # Copy the line number from the original docstring copy_location(target, s) diff --git a/kibot/optionable.py b/kibot/optionable.py index fb349306..4bc5c2fc 100644 --- a/kibot/optionable.py +++ b/kibot/optionable.py @@ -116,27 +116,34 @@ class Optionable(object): # Check the data type cur_doc, alias, is_alias = self.get_doc(k) cur_val = getattr(self, alias) - if isinstance(cur_val, bool): + if cur_doc[0] == '[': + # Separate the valid types for this key + valid = cur_doc[1:].split(']')[0].split('|') + # Remove the XXXX=Value + if '=' in valid[-1]: + valid[-1] = valid[-1].split('=')[0] + # Get the type used by the user as a string + v_type = Optionable._typeof(v) + if v_type not in valid: + # Not a valid type for this key + if v_type == 'None': + raise KiPlotConfigurationError("Empty option `{}`".format(k)) + if len(valid) == 1: + raise KiPlotConfigurationError("Option `{}` must be a {} not `{}`".format(k, valid[0], v_type)) + else: + raise KiPlotConfigurationError("Option `{}` must be any of {} not `{}`".format(k, valid, v_type)) + else: + valid = None + v_type = Optionable._typeof(cur_val) + if v_type == 'boolean': Optionable._check_bool(k, v) - elif isinstance(cur_val, (int, float)): + elif v_type == 'number': Optionable._check_num(k, v, cur_doc) - elif isinstance(cur_val, str): + elif v_type == 'string': Optionable._check_str(k, v, cur_doc) elif isinstance(cur_val, type): # A class, so we need more information i.e. "[dict|string]" - if cur_doc[0] == '[': - # Separate the valid types for this key - valid = cur_doc[1:].split(']')[0].split('|') - # Remove the XXXX=Value - if '=' in valid[-1]: - valid[-1] = valid[-1].split('=')[0] - # Get the type used by the user as a string - v_type = Optionable._typeof(v) - if v_type not in valid: - # Not a valid type for this key - if v_type == 'None': - raise KiPlotConfigurationError("Empty option `{}`".format(k)) - raise KiPlotConfigurationError("Option `{}` must be any of {} not `{}`".format(k, valid, v_type)) + if valid is not None: # We know the type matches, now apply validations if isinstance(v, (int, float)) and not isinstance(v, bool): # Note: booleans are also instance of int diff --git a/kibot/out_base.py b/kibot/out_base.py index 449122ab..73275cdd 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -36,12 +36,13 @@ class BaseOutput(RegOutput): self.comment = '' """ A comment for documentation purposes """ self.extends = '' - """ Copy the options from the indicated output """ + """ Copy the `options` section from the indicated output """ self.run_by_default = True """ When enabled this output will be created when no specific outputs are requested """ self.disable_run_by_default = '' - """ Use it to disable the `run_by_default` status of other output. - Useful when this output extends another and you don't want to generate the original. """ + """ [string|boolean] Use it to disable the `run_by_default` status of other output. + Useful when this output extends another and you don't want to generate the original. + Use the boolean true value to disable the output you are extending """ self.output_id = '' """ Text to use for the %I expansion content. To differentiate variations of this output """ if GS.global_dir: @@ -96,7 +97,7 @@ class BaseOutput(RegOutput): # logger.error("New options: "+str(options)) super().config(parent) to_dis = self.disable_run_by_default - if to_dis: + if isinstance(to_dis, str) and to_dis: # Skip the boolean case out = RegOutput.get_output(to_dis) if out is None: raise KiPlotConfigurationError('Unknown output `{}` in `disable_run_by_default`'.format(to_dis)) diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index ea1e8b1d..50f6f86c 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -293,10 +293,10 @@ def test_filter_not_list(test_dir): ctx.clean_up() -def test_filter_no_number(test_dir): +def test_filter_no_number_1(test_dir): ctx = context.TestContext(test_dir, 'FilterNoNumber', PRJ, 'error_filter_no_number', '') ctx.run(EXIT_BAD_CONFIG) - assert ctx.search_err("Option .?number.? must be a number") + assert ctx.search_err("Empty option .?number.?") ctx.clean_up() @@ -307,10 +307,10 @@ def test_filter_no_number_2(test_dir): ctx.clean_up() -def test_filter_no_regex(test_dir): +def test_filter_no_regex_1(test_dir): ctx = context.TestContext(test_dir, 'FilterNoRegex', PRJ, 'error_filter_no_regex', '') ctx.run(EXIT_BAD_CONFIG) - assert ctx.search_err("Option .?regex.? must be a string") + assert ctx.search_err("Empty option .?regex.?") ctx.clean_up() @@ -441,7 +441,7 @@ def test_error_bom_no_field(test_dir): def test_error_wrong_boolean(test_dir): ctx = context.TestContext(test_dir, 'WrongBoolean', PRJ, 'error_wrong_boolean', '') ctx.run(EXIT_BAD_CONFIG) - assert ctx.search_err(".?exclude_edge_layer.? must be true/false") + assert ctx.search_err(".?exclude_edge_layer.? must be a boolean") ctx.clean_up() diff --git a/tests/yaml_samples/import_test_4.kibot.yaml b/tests/yaml_samples/import_test_4.kibot.yaml index fc8679ad..1a2991c2 100644 --- a/tests/yaml_samples/import_test_4.kibot.yaml +++ b/tests/yaml_samples/import_test_4.kibot.yaml @@ -12,7 +12,7 @@ outputs: type: position dir: positiondir extends: position - disable_run_by_default: position + disable_run_by_default: true options: separate_files_for_front_and_back: false