diff --git a/kibot/optionable.py b/kibot/optionable.py index e795a684..5d3b00d9 100644 --- a/kibot/optionable.py +++ b/kibot/optionable.py @@ -22,8 +22,8 @@ def filter(v): class Optionable(object): """ A class to validate and hold configuration outputs/options. Is configured from a dict and the collected values are stored in its attributes. """ - _str_values_re = compile(r"\[string=.*\] \[([^\]]+)\]") - _num_range_re = compile(r"\[number=.*\] \[(-?\d+),(-?\d+)\]") + _str_values_re = compile(r"string=.*\] \[([^\]]+)\]") + _num_range_re = compile(r"number=.*\] \[(-?\d+),(-?\d+)\]") def __init__(self): self._unkown_is_error = False @@ -37,7 +37,7 @@ class Optionable(object): if not isinstance(val, str): raise KiPlotConfigurationError("Option `{}` must be a string".format(key)) # If the docstring specifies the allowed values in the form [v1,v2...] enforce it - m = Optionable._str_values_re.match(doc) + m = Optionable._str_values_re.search(doc) if m: vals = m.group(1).split(',') if val not in vals: @@ -48,7 +48,7 @@ class Optionable(object): if not isinstance(val, (int, float)): raise KiPlotConfigurationError("Option `{}` must be a number".format(key)) # If the docstring specifies a range in the form [from-to] enforce it - m = Optionable._num_range_re.match(doc) + m = Optionable._num_range_re.search(doc) if m: min = float(m.group(1)) max = float(m.group(2)) diff --git a/kibot/out_pcbdraw.py b/kibot/out_pcbdraw.py index a3c4312a..96369194 100644 --- a/kibot/out_pcbdraw.py +++ b/kibot/out_pcbdraw.py @@ -124,7 +124,7 @@ class PcbDrawOptions(BaseOptions): self.highlight = Optionable """ [list(string)=[]] list of components to highlight """ self.show_components = Optionable - """ [string|list(string)=none] [none,all] list of components to draw, can be also a string for none or all. + """ [list(string)|string=none] [none,all] list of components to draw, can be also a string for none or all. The default is none """ self.vcuts = False """ render V-CUTS on the Cmts.User layer """ diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index 523b53c6..71b52f1c 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -592,3 +592,10 @@ def test_error_wrong_fil_name(): ctx.run(EXIT_BAD_CONFIG) assert ctx.search_err("Filter names starting with (.*) are reserved") ctx.clean_up() + + +def test_error_pcbdraw_comp_key(): + ctx = context.TestContext('test_error_pcbdraw_comp_key', 'bom', 'error_pcbdraw_comp_key', '') + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("Option .?show_components.? must be any of") + ctx.clean_up() diff --git a/tests/yaml_samples/error_pcbdraw_comp_key.kibot.yaml b/tests/yaml_samples/error_pcbdraw_comp_key.kibot.yaml new file mode 100644 index 00000000..00b51ed3 --- /dev/null +++ b/tests/yaml_samples/error_pcbdraw_comp_key.kibot.yaml @@ -0,0 +1,21 @@ +# Example KiBot config file +kibot: + version: 1 + +variants: + - name: 'default' + comment: 'Default variant' + type: ibom + file_id: '-C1' + variants_blacklist: T2,T3 + +outputs: + - name: 'pcbdraw_default' + comment: "PcbDraw w/variant" + type: pcbdraw + options: + variant: default + format: png + # This isn't a good idea, but works + show_components: 'C1' +