From 5a6ab34565fa3d783337a68e07e3500361c8fcf5 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 4 Mar 2019 00:06:32 +0100 Subject: o PartDB: don't die if the directory exist *and* is empty. Ninja creates empty parent directories. o PartDB: escape some path names. o new comamnd: "ninja". Generates a build.ninja from a sch. Not done! --- demo/thirdparty/olinuxino/py/olinuxino.py | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 demo/thirdparty/olinuxino/py/olinuxino.py (limited to 'demo/thirdparty/olinuxino/py') diff --git a/demo/thirdparty/olinuxino/py/olinuxino.py b/demo/thirdparty/olinuxino/py/olinuxino.py new file mode 100644 index 0000000..cc33a81 --- /dev/null +++ b/demo/thirdparty/olinuxino/py/olinuxino.py @@ -0,0 +1,57 @@ +import re + +from ee.kicad import Component +from ee.kicad.make_bom import MakeBomStrategy +from ee.xml import bomFile +from ee.xml.bom_file_utils import facts + + +class OlinuxinoMakeBomStrategy(MakeBomStrategy): + def process_part(self, component: Component, part: bomFile.Part): + print(component.ref) + print(" value={}".format(component.value)) + print(" footprint={}".format(component.footprint)) + + if component.ref_type == "C": + v = component.value + + if v == "NA": + print(" NA".format()) + return part + + na = v.startswith("NA(") and v.endswith(")") + v = v[3:-1] if na else v + + r = re.compile("([0-9]+\\.?[0-9]*[pnum]F)/([0-9]+\\.?[0-9]*[k]?V)/([0-9]+%)(?:/([A-Z][0-9][A-Z]))?") + + m = r.match(v) + + if m: + capacitance = m.group(1) + " F" + voltage = m.group(2) + " V" + tolerance = m.group(3) + "%" + derating = m.group(4) + + print(" capacitance {}".format(capacitance)) + print(" voltage {}".format(voltage)) + print(" tolerance {}".format(tolerance)) + if derating: + print(" derating {}".format(derating)) + if na: + print(" NA".format()) + + fs = facts(part, create=True) + fs.add_fact(bomFile.Fact(key="capacitance", value=capacitance)) + fs.add_fact(bomFile.Fact(key="max_voltage", value=voltage)) + fs.add_fact(bomFile.Fact(key="tolerance", value=tolerance)) + if derating: + fs.add_fact(bomFile.Fact(key="derating", value=derating)) + + else: + print("FAIL") + + return part + + +def make_bom_strategy(): + return OlinuxinoMakeBomStrategy() -- cgit v1.2.3