From e92fb46ec42991dca60d22d8b1ab321b7c4ff146 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 28 Dec 2016 16:37:39 +0100 Subject: o Adding --force flag to digikey-download-for-schematic. o Unbreaking download_product(). --- trygvis/eda/cli/digikey_download_for_schematic.py | 6 +++--- trygvis/eda/cli/digikey_download_metadata.py | 2 +- trygvis/eda/cli/eda_rdf.py | 3 +++ trygvis/eda/cli/make_bom.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'trygvis/eda/cli') diff --git a/trygvis/eda/cli/digikey_download_for_schematic.py b/trygvis/eda/cli/digikey_download_for_schematic.py index 4be2632..bf4f0ce 100755 --- a/trygvis/eda/cli/digikey_download_for_schematic.py +++ b/trygvis/eda/cli/digikey_download_for_schematic.py @@ -5,7 +5,7 @@ from trygvis.eda import cli from trygvis.eda.digikey import * -def work(schematic_url, g): +def work(schematic_url, force, g): client = DigikeyClient() db = DigikeyDatabase() download_category_tree(db, client) @@ -79,9 +79,9 @@ ORDER BY ?digikey_pn [g.add(node) for node in product.to_nodes()] return g - cli.write_graph(download_graph, filename) + cli.write_graph(download_graph, filename, force_write=force) def run(schematic_url, args): cli.info("Schematic: %s" % schematic_url) - cli.with_database(lambda g: work(schematic_url, g)) + cli.with_database(lambda g: work(schematic_url, args.force, g)) diff --git a/trygvis/eda/cli/digikey_download_metadata.py b/trygvis/eda/cli/digikey_download_metadata.py index d807c1a..60880ab 100755 --- a/trygvis/eda/cli/digikey_download_metadata.py +++ b/trygvis/eda/cli/digikey_download_metadata.py @@ -41,5 +41,5 @@ def run(args): for pc in db.productCategories: for sc in pc.subCategories: - output = "%s/digikey-%s.ttl" % (args.output_dir, normalize_filename(sc.label)) + output = "%s/digikey-category-%s.ttl" % (args.output_dir, normalize_filename(sc.label)) do_category(client, sc, output) diff --git a/trygvis/eda/cli/eda_rdf.py b/trygvis/eda/cli/eda_rdf.py index 7b4ed2c..ee4b0dd 100644 --- a/trygvis/eda/cli/eda_rdf.py +++ b/trygvis/eda/cli/eda_rdf.py @@ -9,6 +9,8 @@ class CliCommand(object): self.description = description +# TODO: move all of the command classes to the file they delegate to. + class AddToDb(CliCommand): def __init__(self): super().__init__("add-to-db", "Import RDF triplet file to the database") @@ -55,6 +57,7 @@ class DigikeyDownloadForSchematic(CliCommand): def run(self, argv): p = argparse.ArgumentParser(prog=self.key, description=self.description) p.add_argument("--schematic", required=True) + p.add_argument("-f", "--force", default=False, action='store_true') args = p.parse_args(argv) from trygvis.eda.cli import digikey_download_for_schematic diff --git a/trygvis/eda/cli/make_bom.py b/trygvis/eda/cli/make_bom.py index fcdbe99..8d8c9f1 100755 --- a/trygvis/eda/cli/make_bom.py +++ b/trygvis/eda/cli/make_bom.py @@ -104,4 +104,4 @@ ORDER BY ?ref ?attr_type ?attr_value part = dk_parts[pn] part.set_attribute(row.type, row.value) - cli.info('%5s: %-20s %s' % (pn, row.type + ':', row.value)) + cli.info('%-30s %-50s %s' % (pn, row.type + ':', row.value)) -- cgit v1.2.3