From 0149fcfa2bd9ac8c9f6b05851f7264f005aa2305 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 11 May 2019 14:48:15 +0200 Subject: drawio-to-parts: new tool. ee.xsd: new type: Assembly and AssemblyPart. Should probably be its own file type. ee.part: Better DSL instead of using the raw xml types. --- src/ee/tools/drawio-to-parts.py | 20 -------------------- src/ee/tools/drawio_decompress.py | 2 +- src/ee/tools/drawio_to_parts.py | 25 +++++++++++++++++++++++++ src/ee/tools/templates/build.ninja.j2 | 9 +++++++++ 4 files changed, 35 insertions(+), 21 deletions(-) delete mode 100644 src/ee/tools/drawio-to-parts.py create mode 100644 src/ee/tools/drawio_to_parts.py (limited to 'src/ee/tools') diff --git a/src/ee/tools/drawio-to-parts.py b/src/ee/tools/drawio-to-parts.py deleted file mode 100644 index 562e341..0000000 --- a/src/ee/tools/drawio-to-parts.py +++ /dev/null @@ -1,20 +0,0 @@ -import argparse -from pathlib import Path - -import ee.drawio - -parser = argparse.ArgumentParser() - -parser.add_argument("--in", - dest="in_path", - required=True, - metavar="XML") - -parser.add_argument("--out", - required=True, - metavar="PART DB") - -args = parser.parse_args() - -# ee.drawio.to_parts(Path(args.in_path), Path(args.out)) -ee.drawio.to_dot(Path(args.in_path), Path(args.out)) diff --git a/src/ee/tools/drawio_decompress.py b/src/ee/tools/drawio_decompress.py index 8949eec..8fafd54 100644 --- a/src/ee/tools/drawio_decompress.py +++ b/src/ee/tools/drawio_decompress.py @@ -18,7 +18,7 @@ in_stream = out_stream = None try: in_stream = open(args.in_path, "rb") if args.in_path else sys.stdin - out_stream = open(args.out, "wr") if args.out else sys.stdout + out_stream = open(args.out, "w") if args.out else sys.stdout decompress(in_stream, out_stream) except IOError: diff --git a/src/ee/tools/drawio_to_parts.py b/src/ee/tools/drawio_to_parts.py new file mode 100644 index 0000000..671aaea --- /dev/null +++ b/src/ee/tools/drawio_to_parts.py @@ -0,0 +1,25 @@ +import argparse +from pathlib import Path + +import ee.drawio + +parser = argparse.ArgumentParser() + +parser.add_argument("--in", + dest="in_path", + required=True, + metavar="XML") + +parser.add_argument("--out", + required=True, + metavar="PART DB") + +parser.add_argument("--parts", + nargs="*", + metavar="PART DB") + +args = parser.parse_args() + +parts = args.parts or [] +ee.drawio.to_parts(Path(args.in_path), Path(args.out), [Path(path) for path in parts]) +# ee.drawio.to_dot(Path(args.in_path), Path(args.out)) diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2 index d62f350..b9a65df 100644 --- a/src/ee/tools/templates/build.ninja.j2 +++ b/src/ee/tools/templates/build.ninja.j2 @@ -53,6 +53,15 @@ rule import-parts-yaml description = import-parts-yaml $in command = $ee import-parts-yaml --in $in --out $out +rule drawio-decompress + command = $ee drawio-decompress --in $in --out $out + +rule drawio-to-parts + command = $ee drawio-to-parts --in $in --out $out $args + +rule part-from-excel + command = $ee part-from-excel --in $in --out $out --sheet "$sheet" + {% if gerber_zip is defined %} build gerbers: phony {{ gerber_zip }} build {{ gerber_zip }}: kicad-gerber $pcb -- cgit v1.2.3