diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2017-09-09 08:33:30 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2017-09-09 08:35:20 +0200 |
commit | 2237de33db047b43c8da84a2abe26eb3e3fe6cbe (patch) | |
tree | 3c6d7e5814446e1172fea9c524f3f5b5d0c0d369 /test/test_sch.py | |
parent | 6ea743740ff4524287e5b63a18a45bd19d2451bb (diff) | |
download | ee-python-2237de33db047b43c8da84a2abe26eb3e3fe6cbe.tar.gz ee-python-2237de33db047b43c8da84a2abe26eb3e3fe6cbe.tar.bz2 ee-python-2237de33db047b43c8da84a2abe26eb3e3fe6cbe.tar.xz ee-python-2237de33db047b43c8da84a2abe26eb3e3fe6cbe.zip |
wip: Parsing schematics.
Diffstat (limited to 'test/test_sch.py')
-rw-r--r-- | test/test_sch.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_sch.py b/test/test_sch.py new file mode 100644 index 0000000..a3c6915 --- /dev/null +++ b/test/test_sch.py @@ -0,0 +1,34 @@ +import pytest +import sys +import os.path +from ee.kicad import read_schematic + +basedir = os.path.dirname(os.path.abspath(__file__)) + +def dump_schema(sch): + print("Libraries") + for l in sch.libraries: + print("name: {}".format(l.name)) + + print("Components") + for c in sch.components: + if c.unit != 1: + continue + print("REF: {}, fields={}".format(c.ref if c.unit == 1 else "{}/{}".format(c.ref, c.unit), len(c.fields))) + for f in c.fields: + print(" {}={}".format(f.name, f.value)) + +def load(path): + p = basedir + "/parser/" + path + print("p={}".format(p)) + return read_schematic(p) + +def test_demo_1(): + sch = load("parser-demo-1.sch") + dump_schema(sch) + r101 = sch.get_component("R101") + assert r101 + +def test_sch(): + sch = load("foo.sch") + dump_schema(sch) |