From c96bc5755a68d8e317d96be31b330cc0b626c194 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 9 Sep 2017 22:10:07 +0200 Subject: to_bom: A utility to create a KiCAD-like xml Element of a KiCAD schematic. --- test/test_read_schematic.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_read_schematic.py b/test/test_read_schematic.py index 8edda3b..6d1add7 100644 --- a/test/test_read_schematic.py +++ b/test/test_read_schematic.py @@ -1,7 +1,7 @@ import pytest import sys import os.path -from ee.kicad import read_schematic +#from ee.kicad import read_schematic, to_bom from ee import kicad import ee @@ -26,17 +26,32 @@ def dump_schema(sch): for f in c.fields: print(" {}={}".format(f.name, f.value)) +def dump_bom(sch): + from xml.etree import ElementTree + from xml.dom import minidom + + print("---") + bom = kicad.to_bom(sch) + s = ElementTree.tostring(bom, encoding='unicode') + print(s) + xmlstr = minidom.parseString(s).toprettyxml(indent=" ") + print(xmlstr) + print("---") + def load(path): p = basedir + "/parser/" + path print("p={}".format(p)) - return read_schematic(p) + sch = kicad.read_schematic(p) + return sch def test_demo_1(): sch = load("parser-demo-1.sch") dump_schema(sch) + dump_bom(sch) r101 = sch.get_component("R101") assert r101 def test_sch(): sch = load("foo.sch") dump_schema(sch) + dump_bom(sch) -- cgit v1.2.3