aboutsummaryrefslogtreecommitdiff
path: root/trygvis/eda/__init__.py
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-12-27 01:14:37 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2016-12-27 01:14:37 +0100
commit67013ae17af0436b930dce450a813239be969601 (patch)
tree93a8b34c93080a27674456481d31d6d8b47266cf /trygvis/eda/__init__.py
downloadeda-rdf-67013ae17af0436b930dce450a813239be969601.tar.gz
eda-rdf-67013ae17af0436b930dce450a813239be969601.tar.bz2
eda-rdf-67013ae17af0436b930dce450a813239be969601.tar.xz
eda-rdf-67013ae17af0436b930dce450a813239be969601.zip
o Initial import of some tools for working with KiCAD BOM files and Digi-key.
Diffstat (limited to 'trygvis/eda/__init__.py')
-rw-r--r--trygvis/eda/__init__.py20
1 files changed, 20 insertions, 0 deletions
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)