diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-03-04 00:06:32 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-03-04 00:06:32 +0100 |
commit | 5a6ab34565fa3d783337a68e07e3500361c8fcf5 (patch) | |
tree | c0d4fd9f6986351a543838fabc3dacf8d9ad5fb1 /demo/thirdparty/olinuxino/py | |
parent | 650b4ad3774c4cc454a02073808d981f6873036d (diff) | |
download | ee-python-5a6ab34565fa3d783337a68e07e3500361c8fcf5.tar.gz ee-python-5a6ab34565fa3d783337a68e07e3500361c8fcf5.tar.bz2 ee-python-5a6ab34565fa3d783337a68e07e3500361c8fcf5.tar.xz ee-python-5a6ab34565fa3d783337a68e07e3500361c8fcf5.zip |
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!
Diffstat (limited to 'demo/thirdparty/olinuxino/py')
-rw-r--r-- | demo/thirdparty/olinuxino/py/olinuxino.py | 57 |
1 files changed, 57 insertions, 0 deletions
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() |