Fixed KiBom variants special cases.

When using multiple variants and a components used more than one,
specifying oposite rules.
This commit is contained in:
Salvador E. Tropea 2020-10-09 16:00:52 -03:00
parent 4ea81d80a3
commit 1aee407cb9
5 changed files with 104 additions and 2 deletions

View File

@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Help for filters and variants.
- Support for new `pcbnew_do export` options.
### Fixed
- KiBom variants when using multiple variants and a components used more
than one, specifying oposite rules.
## [0.7.0] - 2020-09-11
### Added
- Now variants are separated entities. Two flavors implemented: KiBoM

View File

@ -76,13 +76,15 @@ class KiBoM(BaseVariant): # noqa: F821
config: content of the 'Config' field (lowercase). """
# Variants logic
opts = config.split(",")
# Only fit for ...
exclusive = False
# Exclude components that match a -VARIANT
for opt in opts:
opt = opt.strip()
# Options that start with '-' are explicitly removed from certain configurations
if opt.startswith("-") and opt[1:] in self.variant:
return False
# Include components that match +VARIANT
exclusive = False
for opt in opts:
# Options that start with '+' are fitted only for certain configurations
if opt.startswith("+"):
exclusive = True

View File

@ -0,0 +1,68 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "KiBom Test Schematic"
Date "2020-03-12"
Rev "A"
Comp "https://github.com/SchrodingersGat/KiBom"
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
Text Notes 500 750 0 79 ~ 0
This schematic serves as a test-file for the KiBot export script.
$Comp
L Device:C C1
U 1 1 5F43BEC2
P 1000 1700
F 0 "C1" H 1115 1746 50 0000 L CNN
F 1 "1nF" H 1115 1655 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric" H 1038 1550 50 0001 C CNN
F 3 "~" H 1000 1700 50 0001 C CNN
F 4 "+A,-B" H 1000 1700 50 0001 C CNN "Config"
1 1000 1700
1 0 0 -1
$EndComp
$Comp
L Device:C C2
U 1 1 5F43CE1C
P 1450 1700
F 0 "C2" H 1565 1746 50 0000 L CNN
F 1 "1000 pF" H 1565 1655 50 0000 L CNN
F 2 "Capacitor_SMD:C_0805_2012Metric" H 1488 1550 50 0001 C CNN
F 3 "~" H 1450 1700 50 0001 C CNN
F 4 "-B,+A" H 1450 1700 50 0001 C CNN "Config"
1 1450 1700
1 0 0 -1
$EndComp
$Comp
L Device:R R1
U 1 1 5F43D144
P 2100 1700
F 0 "R1" H 2170 1746 50 0000 L CNN
F 1 "1k" H 2170 1655 50 0000 L CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2030 1700 50 0001 C CNN
F 3 "~" H 2100 1700 50 0001 C CNN
F 4 "-A" H 2100 1700 50 0001 C CNN "Config"
1 2100 1700
1 0 0 -1
$EndComp
$Comp
L Device:R R2
U 1 1 5F43D4BB
P 2500 1700
F 0 "R2" H 2570 1746 50 0000 L CNN
F 1 "1000" H 2570 1655 50 0000 L CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 1700 50 0001 C CNN
F 3 "~" H 2500 1700 50 0001 C CNN
F 4 "+B" H 2500 1700 50 0001 C CNN "Config"
1 2500 1700
1 0 0 -1
$EndComp
Text Notes 5950 3200 0 118 ~ 0
This test should cover KiBoM #137\ncase suggested by @RomaVis:\n A,B\nC1 \nC2 \nR1 \nR2 X \n
$EndSCHEMATC

View File

@ -1391,3 +1391,13 @@ def test_int_bom_ref_separator():
check_csv_info(info, KIBOM_PRJ_INFO, KIBOM_STATS)
kibom_verif(rows, header, ref_sep=',')
ctx.clean_up()
def test_int_bom_variant_5():
prj = 'kibom-variant_5'
ctx = context.TestContextSCH('test_int_bom_variant_5', prj, 'int_bom_var_5_csv', BOM_DIR)
ctx.run()
rows, header, info = ctx.load_csv(prj+'-bom.csv')
ref_column = header.index(REF_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, 1, ['C1', 'C2', 'R1'], ['R2'])
ctx.clean_up()

View File

@ -0,0 +1,18 @@
# Example KiBot config file
kibot:
version: 1
variants:
- name: 'test multi'
comment: 'Test multi variant'
type: kibom
variant: [A,B]
outputs:
- name: 'bom filtered'
comment: "Bill of Materials test, only R2"
type: bom
dir: BoM
options:
variant: 'test multi'