def main(prettypath, verify=False, verbose=False):
    for pins in list(range(1, 26)) + [32, 36]:
        for generator in (sil, dil, kk):
            if generator == kk and (pins == 1 or pins > 16):
                continue

            # Generate footprint
            name, fp = generator(pins)
            path = os.path.join(prettypath, name + ".kicad_mod")

            if verify and verbose:
                print("Verifying", path)

            # Check if the file already exists and isn't changed
            if os.path.isfile(path):
                with open(path) as f:
                    old = f.read()
                old = [n for n in sexp_parse(old) if n[0] != "tedit"]
                new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
                if new == old:
                    continue

            # If it needs changing, either verification failed or we rewrite
            if verify:
                return False
            else:
                with open(path, "w") as f:
                    f.write(fp)

    if verify:
        return True
Example #2
0
def main(prettypath, verify=False, verbose=False):
    for name, conf in config.items():
        # Generate footprint
        conf['name'] = name
        fp = footprint(conf)
        path = os.path.join(prettypath, name+".kicad_mod")

        if verify and verbose:
            print("Verifying", path)

        # Check if an identical part already exists
        if os.path.isfile(path):
            with open(path) as f:
                old = f.read()
            old = [n for n in sexp_parse(old) if n[0] != "tedit"]
            new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
            if new == old:
                continue

        # If not, either verification failed or we should output the new fp
        if verify:
            return False
        else:
            with open(path, "w") as f:
                f.write(fp)

    # If we finished and didn't return yet, verification has succeeded.
    if verify:
        return True
def main(prettypath, verify=False, verbose=False):
    for pins in range(2, 9):
        for generator in (top_pth_fp, side_pth_fp, top_smd_fp, side_smd_fp):
            # Generate the footprint
            name, fp = generator(pins)
            path = os.path.join(prettypath, name + ".kicad_mod")

            if verify and verbose:
                print("Verifying", path)

            # Check if the file already exists and isn't changed
            if os.path.isfile(path):
                with open(path) as f:
                    old = f.read()
                old = [n for n in sexp_parse(old) if n[0] != "tedit"]
                new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
                if new == old:
                    continue

            # If not, either verification failed or we should output the new fp
            if verify:
                return False
            else:
                with open(path, "w") as f:
                    f.write(fp)

    # If we finished and didn't return yet, verification has succeeded
    if verify:
        return True
Example #4
0
def main(prettypath, verify=False):
    for name, conf in config.items():
        # Generate footprint
        conf['name'] = name
        fp = footprint(conf)
        path = os.path.join(prettypath, name+".kicad_mod")

        if verify:
            print("Verifying", path)

        # Check if an identical part already exists
        if os.path.isfile(path):
            with open(path) as f:
                old = f.read()
            old = [n for n in sexp_parse(old) if n[0] != "tedit"]
            new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
            if new == old:
                continue

        # If not, either verification failed or we should output the new fp
        if verify:
            return False
        else:
            with open(path, "w") as f:
                f.write(fp)

    # If we finished and didn't return yet, verification has succeeded.
    if verify:
        return True
Example #5
0
def main(prettypath, verify=False, verbose=False):
    for pins in range(2, 9):
        for generator in (top_pth_fp, side_pth_fp, top_smd_fp, side_smd_fp):
            # Generate the footprint
            name, fp = generator(pins)
            path = os.path.join(prettypath, name + ".kicad_mod")

            if verify and verbose:
                print("Verifying", path)

            # Check if the file already exists and isn't changed
            if os.path.isfile(path):
                with open(path) as f:
                    old = f.read()
                old = [n for n in sexp_parse(old) if n[0] != "tedit"]
                new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
                if new == old:
                    continue

            # If not, either verification failed or we should output the new fp
            if verify:
                return False
            else:
                with open(path, "w") as f:
                    f.write(fp)

    # If we finished and didn't return yet, verification has succeeded
    if verify:
        return True
def main(prettypath, verify=False):
    for pins in (5, 7, 10):
        for generator in (tfml, tfml_lc, sfml, sfml_lc):
            # Generate footprint
            name, fp = generator(pins)
            path = os.path.join(prettypath, name + ".kicad_mod")

            if verify:
                print("Verifying", path)

            # Check if the file already exists and isn't changed
            if os.path.isfile(path):
                with open(path) as f:
                    old = f.read()
                old = [n for n in sexp_parse(old) if n[0] != "tedit"]
                new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
                if new == old:
                    continue

            # If it needs changing, either verification failed or we rewrite
            if verify:
                return False
            else:
                with open(path, "w") as f:
                    f.write(fp)

    if verify:
        return True
Example #7
0
def main(prettypath, verify=False, verbose=False):
    for name, conf in config.items():
        conf['name'] = name
        assert conf['rows'] in (2, 4), \
            "Must have either two or four rows"
        assert conf['pins'] % conf['rows'] == 0, \
            "Pins must equally divide among rows"
        fp = footprint(conf)
        path = os.path.join(prettypath, name+".kicad_mod")

        if verify and verbose:
            print("Verifying", path)

        # Check if an identical part already exists
        if os.path.isfile(path):
            with open(path) as f:
                old = f.read()
            old = [n for n in sexp_parse(old) if n[0] != "tedit"]
            new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
            if new == old:
                continue

        # If not, either verification failed or we should output the new fp
        if verify:
            return False
        else:
            with open(path, "w") as f:
                f.write(fp)

    # If we finished and didn't return yet, verification has succeeded.
    if verify:
        return True
def main(prettypath, verify=False, verbose=False):
    for pins in (5, 7, 10, 15):
        for generator in (tfml, tfml_lc, sfml, sfml_lc):
            # Generate footprint
            name, fp = generator(pins)
            path = os.path.join(prettypath, name + ".kicad_mod")

            if verify and verbose:
                print("Verifying", path)

            # Check if the file already exists and isn't changed
            if os.path.isfile(path):
                with open(path) as f:
                    old = f.read()
                old = [n for n in sexp_parse(old) if n[0] != "tedit"]
                new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
                if new == old:
                    continue

            # If it needs changing, either verification failed or we rewrite
            if verify:
                return False
            else:
                with open(path, "w") as f:
                    f.write(fp)

    if verify:
        return True
Example #9
0
def main(prettypath, verify=False):
    for name, conf in config.items():
        conf['name'] = name
        assert conf['rows'] in (2, 4), \
            "Must have either two or four rows"
        assert conf['pins'] % conf['rows'] == 0, \
            "Pins must equally divide among rows"
        fp = footprint(conf)
        path = os.path.join(prettypath, name + ".kicad_mod")

        if verify:
            print("Verifying", path)

        # Check if an identical part already exists
        if os.path.isfile(path):
            with open(path) as f:
                old = f.read()
            old = [n for n in sexp_parse(old) if n[0] != "tedit"]
            new = [n for n in sexp_parse(fp) if n[0] != "tedit"]
            if new == old:
                continue

        # If not, either verification failed or we should output the new fp
        if verify:
            return False
        else:
            with open(path, "w") as f:
                f.write(fp)

    # If we finished and didn't return yet, verification has succeeded.
    if verify:
        return True
Example #10
0
def checkmod(path):
    errs = []

    with open(path) as f:
        mod = sexp_parse(f.read())

    checkrefval(mod, errs)
    checkfont(mod, errs)
    checksilk(mod, errs)
    checkctyd(mod, errs)

    if len(errs) == 0:
        print("Checked '{}': OK".format(path))
        return True
    else:
        print("Checked '{}': Error:".format(path), file=sys.stderr)
        for err in errs:
            print("    " + err, file=sys.stderr)
        print("", file=sys.stderr)
        return False
def checkmod(path, verbose=False):
    errs = []

    with open(path) as f:
        mod = sexp_parse(f.read())

    checkrefval(mod, errs)
    checkfont(mod, errs)
    checklines(mod, errs, ("F.SilkS", "B.SilkS"), "0.15")
    checklines(mod, errs, ("F.Fab", "B.Fab"), "0.01")
    checkctyd(mod, errs)

    if len(errs) == 0:
        if verbose:
            print("Checked '{}': OK".format(path))
        return True
    else:
        print("Checked '{}': Error:".format(path), file=sys.stderr)
        for err in errs:
            print("    " + err, file=sys.stderr)
        print("", file=sys.stderr)
        return False
Example #12
0
def main(inpath, outpath, xr, xp, yr, yp):
    with open(inpath) as f:
        insexp = sexp_parse(f.read())

    outsexp = [
        "kicad_pcb",
        ["version", 4],
        ["host", "panelise.py", datetime.datetime.utcnow().isoformat()],
    ]

    simple_types = ("gr_arc", "gr_line", "gr_text", "segment", "via", "module")

    for node in insexp:
        if node[0] in ("page", "layers", "setup", "net", "net_class"):
            outsexp.append(node)
        elif node[0] in simple_types:
            simples(node, outsexp, xr, xp, yr, yp)
        elif node[0] == "zone":
            zones(node, outsexp, xr, xp, yr, yp)

    with open(outpath, "w") as f:
        f.write(sexp_generate(outsexp))
Example #13
0
def main(inpath, outpath, xr, xp, yr, yp):
    with open(inpath) as f:
        insexp = sexp_parse(f.read())

    outsexp = [
        "kicad_pcb",
        ["version", 4],
        ["host", "panelise.py",
         datetime.datetime.utcnow().isoformat()],
    ]

    simple_types = ("gr_arc", "gr_line", "gr_text", "segment", "via", "module")

    for node in insexp:
        if node[0] in ("page", "layers", "setup", "net", "net_class"):
            outsexp.append(node)
        elif node[0] in simple_types:
            simples(node, outsexp, xr, xp, yr, yp)
        elif node[0] == "zone":
            zones(node, outsexp, xr, xp, yr, yp)

    with open(outpath, "w") as f:
        f.write(sexp_generate(outsexp))
Example #14
0
def main(modpath, outpath):
    with open(modpath) as f:
        sexp = sexp_parse(f.read())
    img = draw(sexp)
    img.write_to_png(outpath)
Example #15
0
def main(modpath, outpath):
    with open(modpath) as f:
        sexp = sexp_parse(f.read())
    img = draw(sexp)
    img.write_to_png(outpath)