[Diff][Fixed] Problems with `current` mode

- didn't apply global variants
- didn't honor KiCad native DNP flags, they need a filter
This commit is contained in:
Salvador E. Tropea 2023-12-18 10:36:51 -03:00
parent 4745baccc4
commit 6c336371bd
4 changed files with 32 additions and 10 deletions

View File

@ -119,9 +119,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
temporal, generating problems with the plot outputs, like pcb_print temporal, generating problems with the plot outputs, like pcb_print
- Project options not preserved, i.e. set_text_variables failing - Project options not preserved, i.e. set_text_variables failing
- Bottom QRs should be mirrored in the Y axis - Bottom QRs should be mirrored in the Y axis
- ERC: - Diff
- Problems creating report files without extension (KiCad 7 odd behavior) - `current`: didn't apply global variants
(#529) - `current`: didn't honor KiCad native DNP flags, they need a filter
## [1.6.3] - 2023-06-26 ## [1.6.3] - 2023-06-26

View File

@ -762,6 +762,9 @@ outputs:
# The `stats` mode is used to meassure the amount of difference. In this mode all # The `stats` mode is used to meassure the amount of difference. In this mode all
# changes are red, but you can abort if the difference is bigger than certain threshold # changes are red, but you can abort if the difference is bigger than certain threshold
diff_mode: 'red_green' diff_mode: 'red_green'
# [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
dnf_filter: '_none'
# [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point. # [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point.
# Before doing it KiBot will stash any change. Under some circumstances git could fail # Before doing it KiBot will stash any change. Under some circumstances git could fail
# to do a checkout, even after stashing, this option can workaround the problem. # to do a checkout, even after stashing, this option can workaround the problem.
@ -803,6 +806,9 @@ outputs:
output: '%f-%i%I%v.%x' output: '%f-%i%I%v.%x'
# [boolean=true] Compare the PCB, otherwise compare the schematic # [boolean=true] Compare the PCB, otherwise compare the schematic
pcb: true pcb: true
# [string|list(string)='_none'] Name of the filter to transform fields before applying other filters.
# A short-cut to use for simple cases where a variant is an overkill
pre_transform: '_none'
# [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a # [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a
# difference bigger than the indicated value will make the diff fail. # difference bigger than the indicated value will make the diff fail.
# KiBot will return error level 29 and the diff generation will be aborted # KiBot will return error level 29 and the diff generation will be aborted
@ -810,6 +816,8 @@ outputs:
# [boolean=false] When creating the link name of an output file related to a variant use the variant # [boolean=false] When creating the link name of an output file related to a variant use the variant
# `file_id` instead of its name # `file_id` instead of its name
use_file_id: false use_file_id: false
# [string=''] Board variant to apply
variant: ''
layers: all layers: all
# Datasheets downloader: # Datasheets downloader:
- name: 'download_datasheets_example' - name: 'download_datasheets_example'

View File

@ -49,6 +49,9 @@ Parameters:
- ``diff_mode`` :index:`: <pair: output - diff - options; diff_mode>` [string='red_green'] [red_green,stats] In the `red_green` mode added stuff is green and red when removed. - ``diff_mode`` :index:`: <pair: output - diff - options; diff_mode>` [string='red_green'] [red_green,stats] In the `red_green` mode added stuff is green and red when removed.
The `stats` mode is used to meassure the amount of difference. In this mode all The `stats` mode is used to meassure the amount of difference. In this mode all
changes are red, but you can abort if the difference is bigger than certain threshold. changes are red, but you can abort if the difference is bigger than certain threshold.
- ``dnf_filter`` :index:`: <pair: output - diff - options; 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.
- ``force_checkout`` :index:`: <pair: output - diff - options; force_checkout>` [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point. - ``force_checkout`` :index:`: <pair: output - diff - options; force_checkout>` [boolean=false] When `old_type` and/or `new_type` are `git` KiBot will checkout the indicated point.
Before doing it KiBot will stash any change. Under some circumstances git could fail Before doing it KiBot will stash any change. Under some circumstances git could fail
to do a checkout, even after stashing, this option can workaround the problem. to do a checkout, even after stashing, this option can workaround the problem.
@ -79,11 +82,15 @@ Parameters:
Note that when no differeces are found we get a page saying *No diff*. Note that when no differeces are found we get a page saying *No diff*.
- ``only_first_sch_page`` :index:`: <pair: output - diff - options; only_first_sch_page>` [boolean=false] Compare only the main schematic page (root page). - ``only_first_sch_page`` :index:`: <pair: output - diff - options; only_first_sch_page>` [boolean=false] Compare only the main schematic page (root page).
- ``pcb`` :index:`: <pair: output - diff - options; pcb>` [boolean=true] Compare the PCB, otherwise compare the schematic. - ``pcb`` :index:`: <pair: output - diff - options; pcb>` [boolean=true] Compare the PCB, otherwise compare the schematic.
- ``pre_transform`` :index:`: <pair: output - diff - options; pre_transform>` [string|list(string)='_none'] Name of the filter to transform fields before applying other filters.
A short-cut to use for simple cases where a variant is an overkill.
- ``threshold`` :index:`: <pair: output - diff - options; threshold>` [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a - ``threshold`` :index:`: <pair: output - diff - options; threshold>` [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a
difference bigger than the indicated value will make the diff fail. difference bigger than the indicated value will make the diff fail.
KiBot will return error level 29 and the diff generation will be aborted. KiBot will return error level 29 and the diff generation will be aborted.
- ``use_file_id`` :index:`: <pair: output - diff - options; use_file_id>` [boolean=false] When creating the link name of an output file related to a variant use the variant - ``use_file_id`` :index:`: <pair: output - diff - options; use_file_id>` [boolean=false] When creating the link name of an output file related to a variant use the variant
`file_id` instead of its name. `file_id` instead of its name.
- ``variant`` :index:`: <pair: output - diff - options; variant>` [string=''] Board variant to apply.
- **type** :index:`: <pair: output - diff; type>` [string=''] Type of output. - **type** :index:`: <pair: output - diff; type>` [string=''] Type of output.
- ``category`` :index:`: <pair: output - diff; category>` [string|list(string)=''] The category for this output. If not specified an internally defined category is used. - ``category`` :index:`: <pair: output - diff; category>` [string|list(string)=''] The category for this output. If not specified an internally defined category is used.

View File

@ -31,7 +31,6 @@ from .gs import GS
from .kiplot import load_any_sch, run_command, config_output, get_output_dir, run_output from .kiplot import load_any_sch, run_command, config_output, get_output_dir, run_output
from .layer import Layer from .layer import Layer
from .misc import DIFF_TOO_BIG, FAILED_EXECUTE from .misc import DIFF_TOO_BIG, FAILED_EXECUTE
from .optionable import BaseOptions
from .out_base import VariantOptions from .out_base import VariantOptions
from .registrable import RegOutput from .registrable import RegOutput
from .macros import macros, document, output_class # noqa: F401 from .macros import macros, document, output_class # noqa: F401
@ -41,7 +40,7 @@ logger = log.get_logger()
STASH_MSG = 'KiBot_Changes_Entry' STASH_MSG = 'KiBot_Changes_Entry'
class DiffOptions(BaseOptions): class DiffOptions(VariantOptions):
def __init__(self): def __init__(self):
with document: with document:
self.output = GS.def_global_output self.output = GS.def_global_output
@ -458,12 +457,20 @@ class DiffOptions(BaseOptions):
def cache_current(self): def cache_current(self):
""" The file as we interpreted it """ """ The file as we interpreted it """
if self.pcb: if self.pcb:
fname, dir_name = VariantOptions.save_tmp_dir_board('diff') fname, dir_name = self.save_tmp_dir_board('diff')
self.dirs_to_remove.append(dir_name)
else: else:
dir_name = mkdtemp() if self._comps:
fname = GS.sch.save_variant(dir_name) # We have a variant/filter applied
GS.copy_project_sch(dir_name) dir_name = mkdtemp()
self.dirs_to_remove.append(dir_name) fname = GS.sch.save_variant(dir_name)
GS.copy_project_sch(dir_name)
self.dirs_to_remove.append(dir_name)
else:
# Just use the current file
# Note: The KiCad 7 DNP field needs some filter to be honored
dir_name = GS.sch_dir
fname = os.path.basename(GS.sch_file)
res = self.cache_file(os.path.join(dir_name, fname)) res = self.cache_file(os.path.join(dir_name, fname))
self.git_hash = 'Current' self.git_hash = 'Current'
return res return res