diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-12-27 01:14:37 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-12-27 01:14:37 +0100 |
commit | 67013ae17af0436b930dce450a813239be969601 (patch) | |
tree | 93a8b34c93080a27674456481d31d6d8b47266cf /trygvis/eda/cli/digikey_download_attribute_types_for_category.py | |
download | eda-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/cli/digikey_download_attribute_types_for_category.py')
-rw-r--r-- | trygvis/eda/cli/digikey_download_attribute_types_for_category.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/trygvis/eda/cli/digikey_download_attribute_types_for_category.py b/trygvis/eda/cli/digikey_download_attribute_types_for_category.py new file mode 100644 index 0000000..aef360c --- /dev/null +++ b/trygvis/eda/cli/digikey_download_attribute_types_for_category.py @@ -0,0 +1,29 @@ +from trygvis.eda import cli, write_graph + +from trygvis.eda.digikey import * + + +def run(category, sub_category, output_file, args): + client = DigikeyClient() + db = DigikeyDatabase() + + download_category_tree(db, client) + c = db.find_category(category) + + if c is None: + cli.exit("Could not find category \"%s\"" % category) + + sc = c.find_sub_category_by_label(sub_category) + + if c is None: + cli.exit("Could not find sub-category \"%s\" inside \"%s\"" % (sub_category, category)) + + attributes = download_attribute_types_from_category(sc, client) + db.merge_attribute_types(attributes) + + g = cli.create_graph() + for a in attributes: + [g.add(node) for node in a.to_nodes()] + + filename = output_file if output_file is not "-" else None + write_graph(gen_g=lambda: g, filename=filename) |