From 67013ae17af0436b930dce450a813239be969601 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 27 Dec 2016 01:14:37 +0100 Subject: o Initial import of some tools for working with KiCAD BOM files and Digi-key. --- trygvis/eda/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 trygvis/eda/__init__.py (limited to 'trygvis/eda/__init__.py') diff --git a/trygvis/eda/__init__.py b/trygvis/eda/__init__.py new file mode 100644 index 0000000..e6ccb44 --- /dev/null +++ b/trygvis/eda/__init__.py @@ -0,0 +1,20 @@ +import sys + +from os.path import isfile +from . import cli + + +def write_graph(gen_g, filename=None, force_write=False): + if filename is not None: + if force_write or not isfile(filename): + g = gen_g() + bs = g.serialize(encoding='utf-8', format='turtle') + with open(filename, "wb") as f: + f.write(bs) + cli.info("Wrote %s" % filename) + else: + cli.info("Skipped writing %s, already exists" % filename) + else: + g = gen_g() + bs = g.serialize(encoding='utf-8', format='turtle') + sys.stdout.buffer.write(bs) -- cgit v1.2.3