Fixed variants BoM logic.
The variants logic for BoMs when a component resquested to be only added to more than one variant. This is related to SchrodingersGat/KiBoM#136 issue.
This commit is contained in:
parent
c1d9dd3bfa
commit
140a45fdc6
|
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
|
||||
## [Unreleased]
|
||||
### Fixed
|
||||
- The variants logic for BoMs when a component resquested to be only added to
|
||||
more than one variant.
|
||||
|
||||
## [0.6.1] - 2020-08-20
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -455,6 +455,8 @@ def comp_is_fitted(value, config, variants):
|
|||
return False
|
||||
# Variants logic
|
||||
opts = config.split(",")
|
||||
# Only fit for ...
|
||||
exclusive = False
|
||||
for opt in opts:
|
||||
opt = opt.strip()
|
||||
# Any option containing a DNF is not fitted
|
||||
|
|
@ -464,9 +466,12 @@ def comp_is_fitted(value, config, variants):
|
|||
if opt.startswith("-") and opt[1:] in variants:
|
||||
return False
|
||||
# Options that start with '+' are fitted only for certain configurations
|
||||
if opt.startswith("+") and opt[1:] not in variants:
|
||||
return False
|
||||
return True
|
||||
if opt.startswith("+"):
|
||||
exclusive = True
|
||||
if opt[1:] in variants:
|
||||
return True
|
||||
# No match
|
||||
return not exclusive
|
||||
|
||||
|
||||
def do_bom(file_name, ext, comps, cfg):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
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 600 0 79 ~ 0
|
||||
This schematic serves as a test-file for the KiBot export script.\n
|
||||
Text Notes 5950 2600 0 118 ~ 0
|
||||
The test tests the following \nvariants matrix:\n production test default\nC1 X\nC2 X X\nR1 X X X\nR2 X X\n
|
||||
$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 "" H 1038 1550 50 0001 C CNN
|
||||
F 3 "~" H 1000 1700 50 0001 C CNN
|
||||
F 4 "-production,+test" 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 "" H 1488 1550 50 0001 C CNN
|
||||
F 3 "~" H 1450 1700 50 0001 C CNN
|
||||
F 4 "+production,+test" 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 "" V 2030 1700 50 0001 C CNN
|
||||
F 3 "~" H 2100 1700 50 0001 C CNN
|
||||
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 "" V 2430 1700 50 0001 C CNN
|
||||
F 3 "~" H 2500 1700 50 0001 C CNN
|
||||
F 4 "-test" H 2500 1700 50 0001 C CNN "Config"
|
||||
1 2500 1700
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$EndSCHEMATC
|
||||
|
|
@ -1201,3 +1201,30 @@ def test_int_bom_variant_t1_5():
|
|||
rows, header, info = ctx.load_csv(prj+'-bom.csv')
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
check_kibom_test_netlist(rows, ref_column, 1, ['R2', 'R3'], ['R1', 'R4'])
|
||||
|
||||
|
||||
def test_int_bom_variant_t2_1():
|
||||
prj = 'kibom-variant_2'
|
||||
ctx = context.TestContextSCH('test_int_bom_variant_t2_1', prj, 'int_bom_var_production_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, 2, ['C1'], ['R1', 'R2', 'C2'])
|
||||
|
||||
|
||||
def test_int_bom_variant_t2_2():
|
||||
prj = 'kibom-variant_2'
|
||||
ctx = context.TestContextSCH('test_int_bom_variant_t2_2', prj, 'int_bom_var_test_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, 2, ['R2'], ['R1', 'C1', 'C2'])
|
||||
|
||||
|
||||
def test_int_bom_variant_t2_3():
|
||||
prj = 'kibom-variant_2'
|
||||
ctx = context.TestContextSCH('test_int_bom_variant_t2_3', prj, 'int_bom_simple_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'])
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
variant: production
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
variant: test
|
||||
|
||||
Loading…
Reference in New Issue