INTI-CMNB / KiBot

KiCad automation utility
GNU Affero General Public License v3.0
552 stars 65 forks source link

[BUG] bom output fails when global option set_text_variables_before_output: true #649

Closed soldermate closed 1 month ago

soldermate commented 1 month ago

Describe the bug The bom output fails when the set_text_variables_before_output: true is set. The output works fine when the option is removed (left at the default) This traceback is printed when it fails.

'Spreadsheet for the Bill of Materials' (bom_xlsx) [bom] Traceback (most recent call last): File "/usr/bin/kibot", line 33, in sys.exit(load_entry_point('kibot==1.7.0', 'console_scripts', 'kibot')()) File "/usr/lib/python3/dist-packages/kibot/main.py", line 549, in main generate_outputs(outputs, args.target, args.invert_sel, args.skip_pre, args.cli_order, args.no_priority, File "/usr/lib/python3/dist-packages/kibot/kiplot.py", line 608, in generate_outputs _generate_outputs(outputs, targets, invert, skip_pre, cli_order, no_priority, dont_stop) File "/usr/lib/python3/dist-packages/kibot/kiplot.py", line 598, in _generate_outputs run_output(out, dont_stop) File "/usr/lib/python3/dist-packages/kibot/kiplot.py", line 498, in run_output pre.apply() File "/usr/lib/python3/dist-packages/kibot/pre_set_text_variables.py", line 157, in apply new_text = Optionable.expand_filename_both(self, text, make_safe=False) File "/usr/lib/python3/dist-packages/kibot/optionable.py", line 367, in expand_filename_both name = Optionable.expand_filename_common(self, name, parent) File "/usr/lib/python3/dist-packages/kibot/optionable.py", line 329, in expand_filename_common name = name.replace('%S', _cl(self._find_subpcb())) File "/usr/lib/python3/dist-packages/kibot/pre_base.py", line 207, in _find_subpcb if hasattr(self, '_variant') and self._variant and self.variant._sub_pcb: AttributeError: 'Set_Text_Variables' object has no attribute 'variant'. Did you mean: '_variant'?

To Reproduce Occurs when the following is present in the configuration file


global:
  set_text_variables_before_output: true

outputs:
- name: 'bom_xlsx'
  comment: "Spreadsheet for the Bill of Materials"
  type: bom
  dir: bom
  options: &bom_options
    xlsx:
      title: 'KiBot variants example'
    columns:
      - Row
      - References
      - Quantity Per PCB

Environment Issue occurs in bitbucket pipeline and locally using

image: ghcr.io/inti-cmnb/kicad8_auto_full:latest
clone:
  lfs: false

Additional context Add any other context about the problem here.

set-soft commented 1 month ago

Hi @soldermate ! The above patch should solve it. Thanks for reporting!