From 9a1e1f39e7ca20f68de19d1cb6759d06337c0b2d Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 5 Jan 2021 12:09:29 -0300 Subject: [PATCH] Internal BoM: added `no_conflict` option. Used to exclude fields from conflict detection. --- CHANGELOG.md | 3 +++ README.md | 3 +++ docs/samples/generic_plot.kibot.yaml | 4 ++++ kibot/bom/bom.py | 2 +- kibot/out_bom.py | 13 +++++++++++++ tests/test_plot/test_int_bom.py | 2 ++ tests/yaml_samples/int_bom_fil_dummy.kibot.yaml | 1 + 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3223ac2..1a10c427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- The multipart id to references of multipart components others than part 1. +- Internal BoM: `no_conflict` option to exclude fields from conflict detection. ## [0.9.0] - 2021-01-04 ### Added diff --git a/README.md b/README.md index e71e15ad..91ad2b89 100644 --- a/README.md +++ b/README.md @@ -619,6 +619,9 @@ Next time you need this list just use an alias, like this: - `title`: [string='KiBot Bill of Materials'] BoM title. - `ignore_dnf`: [boolean=true] Exclude DNF (Do Not Fit) components. - `merge_blank_fields`: [boolean=true] Component groups with blank fields will be merged into the most compatible group, where possible. + - `no_conflict`: [list(string)] List of fields where we tolerate conflicts. + Use it to avoid undesired warnings. + By default the field indicated in `fit_field` and the field `part` are excluded. - `normalize_locale`: [boolean=false] When normalizing values use the locale decimal point. - `normalize_values`: [boolean=false] Try to normalize the R, L and C values, producing uniform units and prefixes. - `number`: [number=1] Number of boards to build (components multiplier). diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 978776a9..3602b76d 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -111,6 +111,10 @@ outputs: ignore_dnf: true # [boolean=true] Component groups with blank fields will be merged into the most compatible group, where possible merge_blank_fields: true + # [list(string)] List of fields where we tolerate conflicts. + # Use it to avoid undesired warnings. + # By default the field indicated in `fit_field` and the field `part` are excluded + no_conflict: # [boolean=false] When normalizing values use the locale decimal point normalize_locale: false # [boolean=false] Try to normalize the R, L and C values, producing uniform units and prefixes diff --git a/kibot/bom/bom.py b/kibot/bom/bom.py index c9762817..3e7cc1f6 100644 --- a/kibot/bom/bom.py +++ b/kibot/bom/bom.py @@ -214,7 +214,7 @@ class ComponentGroup(object): else: # Config contains variant information, which is different for each component # Part can be one of the defined aliases - if field != self.cfg.fit_field and field != 'part': + if field not in self.cfg.no_conflict: logger.warning(W_FIELDCONF + "Field conflict: ({refs}) [{name}] : '{flds}' <- '{fld}' (in {ref})".format( refs=self.get_refs(), name=field, diff --git a/kibot/out_bom.py b/kibot/out_bom.py index 502570a1..64a687e4 100644 --- a/kibot/out_bom.py +++ b/kibot/out_bom.py @@ -243,6 +243,10 @@ class BoMOptions(BaseOptions): - ['sw', 'switch'] - ['zener', 'zenersmall'] - ['d', 'diode', 'd_small'] """ + self.no_conflict = Optionable + """ [list(string)] List of fields where we tolerate conflicts. + Use it to avoid undesired warnings. + By default the field indicated in `fit_field` and the field `part` are excluded """ super().__init__() @staticmethod @@ -317,6 +321,15 @@ class BoMOptions(BaseOptions): self._normalize_variant() # Field names are handled in lowercase self.fit_field = self.fit_field.lower() + # Fields excluded from conflict warnings + no_conflict = set() + if isinstance(self.no_conflict, type): + no_conflict.add(self.fit_field) + no_conflict.add('part') + else: + for field in self.no_conflict: + no_conflict.add(field.lower()) + self.no_conflict = no_conflict # Columns self.column_rename = {} self.join = [] diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index 19346547..16e1bed9 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -1302,6 +1302,7 @@ def test_int_bom_fil_dummy(): rows, header, info = ctx.load_csv(prj+'-bom.csv') ref_column = header.index(REF_COLUMN_NAME) check_kibom_test_netlist(rows, ref_column, 4, None, ['R1-R2', 'R3-R4', 'R5-R6', 'C1-C2']) + ctx.search_err('Field conflict', invert=True) ctx.clean_up() @@ -1322,6 +1323,7 @@ def test_int_bom_fil_1(): check_kibom_test_netlist(rows, ref_column, 2, None, ['R1', 'C1-C2']) rows, header, info = ctx.load_csv('multi.csv') check_kibom_test_netlist(rows, ref_column, 1, None, ['C1-C2']) + ctx.search_err('Field conflict') ctx.clean_up() diff --git a/tests/yaml_samples/int_bom_fil_dummy.kibot.yaml b/tests/yaml_samples/int_bom_fil_dummy.kibot.yaml index 8d1edc67..a7fae113 100644 --- a/tests/yaml_samples/int_bom_fil_dummy.kibot.yaml +++ b/tests/yaml_samples/int_bom_fil_dummy.kibot.yaml @@ -10,4 +10,5 @@ outputs: options: use_alt: true exclude_filter: '' + no_conflict: ['bb']