diff --git a/CHANGELOG.md b/CHANGELOG.md index 930a3506..9e933af7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 These fields are now part of the default `group_fields`. (#79) - JLCPCB example, to match current recommendations (g200kg/kicad-gerberzipper#11) +- Internal BoM: the field used for variants doesn't produce conflicts. (#100) ### Fixed - Position files now defaults to use the auxiliar origin as KiCad. diff --git a/README.md b/README.md index 2f37b675..160e68a8 100644 --- a/README.md +++ b/README.md @@ -720,7 +720,7 @@ Next time you need this list just use an alias, like this: - `merge_both_blank`: [boolean=true] When creating groups two components with empty/missing field will be interpreted as with the same value. - `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. + By default the field indicated in `fit_field`, the field used for variants and the field `part` are excluded. - `no_distributors`: [string|list(string)] Exclude this distributors list. They are removed after computing `distributors`. - `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. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index b406b66d..7881ba1a 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -169,7 +169,7 @@ outputs: merge_both_blank: 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 + # By default the field indicated in `fit_field`, the field used for variants and the field `part` are excluded no_conflict: ['Config', 'Part'] # [string|list(string)] Exclude this distributors list. They are removed after computing `distributors` no_distributors: diff --git a/kibot/out_bom.py b/kibot/out_bom.py index 119b95c2..7425778e 100644 --- a/kibot/out_bom.py +++ b/kibot/out_bom.py @@ -295,7 +295,7 @@ class BoMOptions(BaseOptions): self.no_conflict = NoConflict """ [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 """ + By default the field indicated in `fit_field`, the field used for variants and the field `part` are excluded """ self.aggregate = Aggregate """ [list(dict)] Add components from other projects """ self.ref_id = '' @@ -459,6 +459,9 @@ class BoMOptions(BaseOptions): if isinstance(self.no_conflict, type): no_conflict.add(self.fit_field) no_conflict.add('part') + var_field = self.variant.get_variant_field() + if var_field is not None: + no_conflict.add(var_field) else: for field in self.no_conflict: no_conflict.add(field.lower()) diff --git a/kibot/var_base.py b/kibot/var_base.py index baabad04..3e27d475 100644 --- a/kibot/var_base.py +++ b/kibot/var_base.py @@ -39,6 +39,10 @@ class BaseVariant(RegVariant): """ [string|list(string)=''] Name of the filter to mark components as 'Do Not Change'. Use '_kibom_dnc' for the default KiBoM behavior """ + def get_variant_field(self): + ''' Returns the name of the field used to determine if the component belongs to teh variant ''' + return None + def filter(self, comps): # Apply all the filters comps = apply_pre_transform(comps, self.pre_transform) diff --git a/kibot/var_ibom.py b/kibot/var_ibom.py index 8f98f4ba..753ebb08 100644 --- a/kibot/var_ibom.py +++ b/kibot/var_ibom.py @@ -32,6 +32,10 @@ class IBoM(BaseVariant): # noqa: F821 self.variants_whitelist = Optionable """ [string|list(string)=''] List of board variants to include in the BOM """ + def get_variant_field(self): + ''' Returns the name of the field used to determine if the component belongs to teh variant ''' + return self.variant_field + def config(self, parent): super().config(parent) self.pre_transform = BaseFilter.solve_filter(self.pre_transform, 'pre_transform', is_transform=True) diff --git a/kibot/var_kibom.py b/kibot/var_kibom.py index 13716d2d..4c7e0618 100644 --- a/kibot/var_kibom.py +++ b/kibot/var_kibom.py @@ -33,6 +33,10 @@ class KiBoM(BaseVariant): # noqa: F821 self.variant = Optionable """ [string|list(string)=''] Board variant(s) """ + def get_variant_field(self): + ''' Returns the name of the field used to determine if the component belongs to teh variant ''' + return self.config_field + def set_def_filters(self, exclude_filter, dnf_filter, dnc_filter): """ Filters delegated to the variant """ self._def_exclude_filter = exclude_filter diff --git a/kibot/var_kicost.py b/kibot/var_kicost.py index 190c290c..1fd7c003 100644 --- a/kibot/var_kicost.py +++ b/kibot/var_kicost.py @@ -36,6 +36,10 @@ class KiCost(BaseVariant): # noqa: F821 """ Valid separators for variants in the variant field. Each character is a valid separator """ + def get_variant_field(self): + ''' Returns the name of the field used to determine if the component belongs to teh variant ''' + return self.variant_field + def config(self, parent): super().config(parent) self.pre_transform = BaseFilter.solve_filter(self.pre_transform, 'pre_transform',