parent
5058af5038
commit
99bec61576
|
|
@ -190,8 +190,9 @@ class ComponentGroup(object):
|
|||
return self.fields[field]
|
||||
|
||||
def sort_components(self):
|
||||
""" Sort the components in correct order (by reference) """
|
||||
self.components = sorted(self.components, key=lambda c: [c.ref_prefix, c.ref_suffix])
|
||||
""" Sort the components in correct order (by reference).
|
||||
First priority is the prefix, second the number (as integer) """
|
||||
self.components = sorted(self.components, key=lambda c: [c.ref_prefix, int(c.ref_suffix)])
|
||||
|
||||
def get_refs(self):
|
||||
""" Return a list of the components """
|
||||
|
|
|
|||
|
|
@ -0,0 +1,262 @@
|
|||
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
|
||||
$Comp
|
||||
L Device:R R1
|
||||
U 1 1 5E6A2873
|
||||
P 2200 2550
|
||||
F 0 "R1" V 2280 2550 50 0000 C CNN
|
||||
F 1 "10K" V 2200 2550 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2130 2550 50 0001 C CNN
|
||||
F 3 "~" H 2200 2550 50 0001 C CNN
|
||||
1 2200 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R2
|
||||
U 1 1 5E6A330D
|
||||
P 2500 2550
|
||||
F 0 "R2" V 2580 2550 50 0000 C CNN
|
||||
F 1 "8.2k" V 2500 2550 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 2550 50 0001 C CNN
|
||||
F 3 "~" H 2500 2550 50 0001 C CNN
|
||||
1 2500 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R3
|
||||
U 1 1 5E6A35E1
|
||||
P 2750 2550
|
||||
F 0 "R3" V 2830 2550 50 0000 C CNN
|
||||
F 1 "6k8" V 2750 2550 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2680 2550 50 0001 C CNN
|
||||
F 3 "~" H 2750 2550 50 0001 C CNN
|
||||
1 2750 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R6
|
||||
U 1 1 5E6A3CA0
|
||||
P 2200 3100
|
||||
F 0 "R6" V 2280 3100 50 0000 C CNN
|
||||
F 1 "1M" V 2200 3100 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2130 3100 50 0001 C CNN
|
||||
F 3 "~" H 2200 3100 50 0001 C CNN
|
||||
F 4 "DNF" V 2200 3100 50 0001 C CNN "Config"
|
||||
1 2200 3100
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R7
|
||||
U 1 1 5E6A3F38
|
||||
P 2500 3100
|
||||
F 0 "R7" V 2580 3100 50 0000 C CNN
|
||||
F 1 "2M2" V 2500 3100 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 3100 50 0001 C CNN
|
||||
F 3 "~" H 2500 3100 50 0001 C CNN
|
||||
F 4 "DNC" V 2500 3100 50 0001 C CNN "Config"
|
||||
1 2500 3100
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R8
|
||||
U 1 1 5E6A4181
|
||||
P 2750 3100
|
||||
F 0 "R8" V 2830 3100 50 0000 C CNN
|
||||
F 1 "1.2M" V 2750 3100 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2680 3100 50 0001 C CNN
|
||||
F 3 "~" H 2750 3100 50 0001 C CNN
|
||||
1 2750 3100
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R9
|
||||
U 1 1 5E6A448B
|
||||
P 2200 3650
|
||||
F 0 "R9" V 2280 3650 50 0000 C CNN
|
||||
F 1 "100R" V 2200 3650 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0603_1608Metric" V 2130 3650 50 0001 C CNN
|
||||
F 3 "~" H 2200 3650 50 0001 C CNN
|
||||
1 2200 3650
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R10
|
||||
U 1 1 5E6A491A
|
||||
P 2500 3650
|
||||
F 0 "R10" V 2580 3650 50 0000 C CNN
|
||||
F 1 "100" V 2500 3650 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0603_1608Metric" V 2430 3650 50 0001 C CNN
|
||||
F 3 "~" H 2500 3650 50 0001 C CNN
|
||||
1 2500 3650
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
Text Notes 550 950 0 50 ~ 0
|
||||
This schematic serves as a test-file for the KiBom export script.\n\nAfter making a change to the schematic, remember to re-export the BOM to generate the intermediate .xml file\n\n(The testing framework cannot perform the netlist-export step!)
|
||||
$Comp
|
||||
L Device:C C1
|
||||
U 1 1 5E6A62CC
|
||||
P 6650 2550
|
||||
F 0 "C1" H 6675 2650 50 0000 L CNN
|
||||
F 1 "10nF" H 6675 2450 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 6688 2400 50 0001 C CNN
|
||||
F 3 "~" H 6650 2550 50 0001 C CNN
|
||||
1 6650 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C2
|
||||
U 1 1 5E6A6854
|
||||
P 7050 2550
|
||||
F 0 "C2" H 7075 2650 50 0000 L CNN
|
||||
F 1 "10n" H 7075 2450 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7088 2400 50 0001 C CNN
|
||||
F 3 "~" H 7050 2550 50 0001 C CNN
|
||||
1 7050 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C3
|
||||
U 1 1 5E6A6A34
|
||||
P 7450 2550
|
||||
F 0 "C3" H 7475 2650 50 0000 L CNN
|
||||
F 1 "0.01uF" H 7475 2450 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7488 2400 50 0001 C CNN
|
||||
F 3 "~" H 7450 2550 50 0001 C CNN
|
||||
1 7450 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C4
|
||||
U 1 1 5E6A6CB6
|
||||
P 7900 2550
|
||||
F 0 "C4" H 7925 2650 50 0000 L CNN
|
||||
F 1 "0.01uf" H 7925 2450 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7938 2400 50 0001 C CNN
|
||||
F 3 "~" H 7900 2550 50 0001 C CNN
|
||||
1 7900 2550
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C5
|
||||
U 1 1 5F1091D6
|
||||
P 6650 3000
|
||||
F 0 "C5" H 6675 3100 50 0000 L CNN
|
||||
F 1 "3.3pF" H 6675 2900 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 6688 2850 50 0001 C CNN
|
||||
F 3 "~" H 6650 3000 50 0001 C CNN
|
||||
1 6650 3000
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C6
|
||||
U 1 1 5F1091E0
|
||||
P 7050 3000
|
||||
F 0 "C6" H 7075 3100 50 0000 L CNN
|
||||
F 1 "3.3 pF" H 7075 2900 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7088 2850 50 0001 C CNN
|
||||
F 3 "~" H 7050 3000 50 0001 C CNN
|
||||
1 7050 3000
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C7
|
||||
U 1 1 5F1091EA
|
||||
P 7450 3000
|
||||
F 0 "C7" H 7475 3100 50 0000 L CNN
|
||||
F 1 "0.0033nF" H 7475 2900 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7488 2850 50 0001 C CNN
|
||||
F 3 "~" H 7450 3000 50 0001 C CNN
|
||||
1 7450 3000
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C8
|
||||
U 1 1 5F1091F4
|
||||
P 7900 3000
|
||||
F 0 "C8" H 7925 3100 50 0000 L CNN
|
||||
F 1 "3.3pf" H 7925 2900 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7938 2850 50 0001 C CNN
|
||||
F 3 "~" H 7900 3000 50 0001 C CNN
|
||||
1 7900 3000
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C9
|
||||
U 1 1 5F10B616
|
||||
P 6650 3500
|
||||
F 0 "C9" H 6675 3600 50 0000 L CNN
|
||||
F 1 "5.6pF" H 6675 3400 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 6688 3350 50 0001 C CNN
|
||||
F 3 "~" H 6650 3500 50 0001 C CNN
|
||||
1 6650 3500
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C10
|
||||
U 1 1 5F10B620
|
||||
P 7050 3500
|
||||
F 0 "C10" H 7075 3600 50 0000 L CNN
|
||||
F 1 "5.6 nF" H 7075 3400 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7088 3350 50 0001 C CNN
|
||||
F 3 "~" H 7050 3500 50 0001 C CNN
|
||||
1 7050 3500
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C11
|
||||
U 1 1 5F10B62A
|
||||
P 7450 3500
|
||||
F 0 "C11" H 7475 3600 50 0000 L CNN
|
||||
F 1 "5.6 uF" H 7475 3400 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7488 3350 50 0001 C CNN
|
||||
F 3 "~" H 7450 3500 50 0001 C CNN
|
||||
1 7450 3500
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:C C12
|
||||
U 1 1 5F10B634
|
||||
P 7900 3500
|
||||
F 0 "C12" H 7925 3600 50 0000 L CNN
|
||||
F 1 "8.2uF" H 7925 3400 50 0000 L CNN
|
||||
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7938 3350 50 0001 C CNN
|
||||
F 3 "~" H 7900 3500 50 0001 C CNN
|
||||
1 7900 3500
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R4
|
||||
U 1 1 5F10E332
|
||||
P 2750 3650
|
||||
F 0 "R4" V 2830 3650 50 0000 C CNN
|
||||
F 1 "3R3" V 2750 3650 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0603_1608Metric" V 2680 3650 50 0001 C CNN
|
||||
F 3 "~" H 2750 3650 50 0001 C CNN
|
||||
1 2750 3650
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$Comp
|
||||
L Device:R R5
|
||||
U 1 1 5F10D5C6
|
||||
P 2200 4150
|
||||
F 0 "R5" V 2280 4150 50 0000 C CNN
|
||||
F 1 "22m" V 2200 4150 50 0000 C CNN
|
||||
F 2 "Resistor_SMD:R_0603_1608Metric" V 2130 4150 50 0001 C CNN
|
||||
F 3 "~" H 2200 4150 50 0001 C CNN
|
||||
1 2200 4150
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
$EndSCHEMATC
|
||||
|
|
@ -144,3 +144,26 @@ def test_int_bom_simple_xlsx():
|
|||
check_kibom_test_netlist(rows, ref_column, KIBOM_TEST_GROUPS, KIBOM_TEST_EXCLUDE, KIBOM_TEST_COMPONENTS)
|
||||
check_dnc(rows, 'R7', ref_column, qty_column)
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def get_components(rows, col):
|
||||
components = []
|
||||
for r in rows:
|
||||
components.extend(r[col].split())
|
||||
return components
|
||||
|
||||
|
||||
def test_int_bom_sort_1():
|
||||
prj = 'RLC_sort'
|
||||
ext = 'csv'
|
||||
ctx = context.TestContext('test_int_bom_sort_1', prj, 'int_bom_simple_csv', BOM_DIR)
|
||||
ctx.run(no_board_file=True, extra=['-e', os.path.join(ctx.get_board_dir(), prj+'.sch')])
|
||||
out = prj + '-bom.' + ext
|
||||
rows, header = ctx.load_csv(out)
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
exp = ['C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C1', 'C2', 'C3', 'C4', 'C11', 'C12',
|
||||
'R5', 'R4', 'R9', 'R10', 'R3', 'R2', 'R1', 'R8', 'R7']
|
||||
check_kibom_test_netlist(rows, ref_column, 14, None, exp)
|
||||
# Check the sorting
|
||||
assert get_components(rows, ref_column) == exp
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
Loading…
Reference in New Issue