From f27dc68e4f20a20cb171ffa80fb300e91ecaf4a9 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 25 Apr 2021 11:16:40 -0300 Subject: [PATCH] Refined what is filtered from the CSV comparisson in KiCost tests --- .../5_1_6/KiCost/kibom-variant_2c-bom.csv | 5 ++++- .../5_1_6/KiCost/kibom-variant_2c-bom_dnf.csv | 5 ++++- tests/reference/5_1_6/KiCost/simple.csv | 2 ++ tests/reference/5_1_6/KiCost/simple_default.csv | 2 ++ .../reference/5_1_6/KiCost/simple_production.csv | 2 ++ tests/reference/5_1_6/KiCost/simple_test.csv | 2 ++ tests/test_plot/test_kicost.py | 15 +++++++++++---- 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom.csv b/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom.csv index e72c2361..ada31244 100644 --- a/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom.csv +++ b/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom.csv @@ -3,11 +3,14 @@ ,,,,Variant:,default,,,,Unit Cost:,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,Revision:,A,,,,Total Cost:,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0 ,,,,Date:,2021-04-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,,,,KiCad Version:,5.1.9+dfsg1-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,KiCad Version:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Global Part Info,,,,,,,,,,,Arrow,,,,,Digi-Key,,,,,Farnell,,,,,LCSC,,,,,Mouser,,,,,Newark,,,,,RS Components,,,,,TME,,,,,test,,,, References,Value,Real value,Tolerancia,Voltage,Footprint,Manufacturer,Manufacturer P/N,Build Quantity,Unit$,Ext$,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat# R1 R2,1k,1000,1%,,,Bourns,CR0603-JW-102ELF,100,0,0,,,,,,51387,,0,0,CR0603-JW-102ELFCT-ND,55000,,0,0,2333561,,,,,,52251,,0,0,652CR0603JW102ELF,110000,,0,0,02J2284,,,,,,,,,,,,,,, +,Used currency rates:,,,,,,,,Total Purchase:,0,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,,0,,0, ,USD($)/GBP(£):,1.375941592305018,,,,,,,Purchase description:,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Created:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +KiCost,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom_dnf.csv b/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom_dnf.csv index 636bed71..5c520d0c 100644 --- a/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom_dnf.csv +++ b/tests/reference/5_1_6/KiCost/kibom-variant_2c-bom_dnf.csv @@ -3,12 +3,15 @@ ,,,,Variant:,default,,,,Unit Cost:,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,Revision:,A,,,,Total Cost:,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0,,,,0,0 ,,,,Date:,2021-04-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,,,,KiCad Version:,5.1.9+dfsg1-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,KiCad Version:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Global Part Info,,,,,,,,,,,Arrow,,,,,Digi-Key,,,,,Farnell,,,,,LCSC,,,,,Mouser,,,,,Newark,,,,,RS Components,,,,,TME,,,,,test,,,, References,Value,Real value,Tolerancia,Voltage,Footprint,Manufacturer,Manufacturer P/N,Build Quantity,Unit$,Ext$,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat#,Avail,Purch,Unit$,Ext$,Cat# C1 C2,1nF, 1000pF,20%,50 V 100 V,,Samsung,CL10B102KC8NNNC,100,0,0,,,,,,NonStk,,0,0,1276-1131-1-ND,3860,,0,0,3013404,542250,,0,0,C153291,NonStk,,0,0,187CL10B102KC8NNNC,19600,,0,0,82AC9311,NonStk,,0,0,7665480,5789,,0,0,CL10B102KC8NNNC,,,,, +,Used currency rates:,,,,,,,,Total Purchase:,0,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,Buy here,0,,0,,,0,,0, ,USD($)/EUR(€):,1.1873,,,,,,,Purchase description:,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,,,,0,,, ,USD($)/GBP(£):,1.375941592305018,,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Created:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +KiCost,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/tests/reference/5_1_6/KiCost/simple.csv b/tests/reference/5_1_6/KiCost/simple.csv index 558f826b..e1aada77 100644 --- a/tests/reference/5_1_6/KiCost/simple.csv +++ b/tests/reference/5_1_6/KiCost/simple.csv @@ -1,9 +1,11 @@ Prj:,KiBom Test Schematic,,,,Board Qty:,100 Co.:,https://github.com/SchrodingersGat/KiBom,,,,Unit Cost:,0 Prj date:,mar 30 mar 2021 09:46:24,,,,Total Cost:,0 +$ date:,,,,,, Global Part Info,,,,,, Refs,Value,Footprint,Manf#,Qty,Unit$,Ext$ C1,1nF,,,100,,0 R1,1k,,,100,,0 +KiCost,,,,,, diff --git a/tests/reference/5_1_6/KiCost/simple_default.csv b/tests/reference/5_1_6/KiCost/simple_default.csv index 883b9805..94f4d484 100644 --- a/tests/reference/5_1_6/KiCost/simple_default.csv +++ b/tests/reference/5_1_6/KiCost/simple_default.csv @@ -1,9 +1,11 @@ Prj:,KiBom Test Schematic,,,,Board Qty:,100 Co.:,https://github.com/SchrodingersGat/KiBom,,,,Unit Cost:,0 Prj date:,mar 30 mar 2021 09:46:24,,,,Total Cost:,0 +$ date:,,,,,, Global Part Info,,,,,, Refs,Value,Footprint,Manf#,Qty,Unit$,Ext$ R1,1k,,,100,,0 R2,1000,,,100,,0 +KiCost,,,,,, diff --git a/tests/reference/5_1_6/KiCost/simple_production.csv b/tests/reference/5_1_6/KiCost/simple_production.csv index 9c3da1eb..8343547d 100644 --- a/tests/reference/5_1_6/KiCost/simple_production.csv +++ b/tests/reference/5_1_6/KiCost/simple_production.csv @@ -1,6 +1,7 @@ Prj:,KiBom Test Schematic,,,,Board Qty:,100 Co.:,https://github.com/SchrodingersGat/KiBom,,,,Unit Cost:,0 Prj date:,mar 30 mar 2021 09:46:24,,,,Total Cost:,0 +$ date:,,,,,, Global Part Info,,,,,, Refs,Value,Footprint,Manf#,Qty,Unit$,Ext$ C2,1000 pF,,,100,,0 @@ -8,3 +9,4 @@ R1,1k,,,100,,0 R2,1000,,,100,,0 +KiCost,,,,,, diff --git a/tests/reference/5_1_6/KiCost/simple_test.csv b/tests/reference/5_1_6/KiCost/simple_test.csv index 8af2e2da..94b36c84 100644 --- a/tests/reference/5_1_6/KiCost/simple_test.csv +++ b/tests/reference/5_1_6/KiCost/simple_test.csv @@ -1,6 +1,7 @@ Prj:,KiBom Test Schematic,,,,Board Qty:,100 Co.:,https://github.com/SchrodingersGat/KiBom,,,,Unit Cost:,0 Prj date:,mar 30 mar 2021 09:46:24,,,,Total Cost:,0 +$ date:,,,,,, Global Part Info,,,,,, Refs,Value,Footprint,Manf#,Qty,Unit$,Ext$ C1,1nF,,,100,,0 @@ -8,3 +9,4 @@ C2,1000 pF,,,100,,0 R1,3k3,,,100,,0 +KiCost,,,,,, diff --git a/tests/test_plot/test_kicost.py b/tests/test_plot/test_kicost.py index 81722906..7dd263ca 100644 --- a/tests/test_plot/test_kicost.py +++ b/tests/test_plot/test_kicost.py @@ -7,6 +7,7 @@ pytest-3 --log-cli-level debug import os.path as op import sys +import re # Look for the 'utils' module from where the script is running prev_dir = op.dirname(op.dirname(op.abspath(__file__))) if prev_dir not in sys.path: @@ -29,10 +30,16 @@ def convert2csv(xlsx, skip_empty=False, sheet=None): if sheet: cmd.extend(['-n', sheet]) cmd.append(xlsx) - p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE) - with open(csv, 'w') as f: - p2 = subprocess.Popen(['egrep', '-i', '-v', r'(\$ date|created|kicost|Total purchase)'], stdin=p1.stdout, stdout=f) - p2.communicate()[0] + cmd.append(csv) + subprocess.check_output(cmd) + with open(csv, 'rt') as f: + content = f.read() + content = re.sub(r'\$ date:,[^,]+', '$ date:,', content, 1) + content = re.sub(r'KiCost[^,]+', 'KiCost', content, 1) + content = re.sub(r'KiCad Version:,[^,]+', 'KiCad Version:,', content) + content = re.sub(r'Created:,[^,]+', 'Created:,', content, 1) + with open(csv, 'wt') as f: + f.write(content) def check_simple(ctx, variant):