Skip to content

Commit

Permalink
[Diff][Fixed] Problems with current mode
Browse files Browse the repository at this point in the history
- didn't apply global variants
- didn't honor KiCad native DNP flags, they need a filter
  • Loading branch information
set-soft committed Dec 18, 2023
1 parent 4745bac commit 6c33637
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Project options not preserved, i.e. set_text_variables failing
- Bottom QRs should be mirrored in the Y axis
- ERC:
- Problems creating report files without extension (KiCad 7 odd behavior)
(#529)
- Diff
- `current`: didn't apply global variants
- `current`: didn't honor KiCad native DNP flags, they need a filter


## [1.6.3] - 2023-06-26
Expand Down
8 changes: 8 additions & 0 deletions docs/samples/generic_plot.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,9 @@ outputs:
# 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
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.
# 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.
Expand Down Expand Up @@ -803,13 +806,18 @@ outputs:
output: '%f-%i%I%v.%x'
# [boolean=true] Compare the PCB, otherwise compare the schematic
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
# difference bigger than the indicated value will make the diff fail.
# KiBot will return error level 29 and the diff generation will be aborted
threshold: 0
# [boolean=false] When creating the link name of an output file related to a variant use the variant
# `file_id` instead of its name
use_file_id: false
# [string=''] Board variant to apply
variant: ''
layers: all
# Datasheets downloader:
- name: 'download_datasheets_example'
Expand Down
7 changes: 7 additions & 0 deletions docs/source/configuration/outputs/diff.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
- ``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.
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.
Expand Down Expand Up @@ -79,11 +82,15 @@ Parameters:
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).
- ``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
difference bigger than the indicated value will make the diff fail.
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
`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.
- ``category`` :index:`: <pair: output - diff; category>` [string|list(string)=''] The category for this output. If not specified an internally defined category is used.
Expand Down
21 changes: 14 additions & 7 deletions kibot/out_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from .kiplot import load_any_sch, run_command, config_output, get_output_dir, run_output
from .layer import Layer
from .misc import DIFF_TOO_BIG, FAILED_EXECUTE
from .optionable import BaseOptions
from .out_base import VariantOptions
from .registrable import RegOutput
from .macros import macros, document, output_class # noqa: F401
Expand All @@ -41,7 +40,7 @@
STASH_MSG = 'KiBot_Changes_Entry'


class DiffOptions(BaseOptions):
class DiffOptions(VariantOptions):
def __init__(self):
with document:
self.output = GS.def_global_output
Expand Down Expand Up @@ -458,12 +457,20 @@ def cache_output(self, name):
def cache_current(self):
""" The file as we interpreted it """
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:
dir_name = mkdtemp()
fname = GS.sch.save_variant(dir_name)
GS.copy_project_sch(dir_name)
self.dirs_to_remove.append(dir_name)
if self._comps:
# We have a variant/filter applied
dir_name = mkdtemp()
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))
self.git_hash = 'Current'
return res
Expand Down

0 comments on commit 6c33637

Please sign in to comment.