aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-01-02 08:32:37 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2017-01-02 08:32:37 +0100
commit7ec05971895a0428c9912a930d789ec7bf004a32 (patch)
treef0a2f0db6cbd78efbe971da81bfe99420fae8d94
parent8c90d2e409e9c457a8e27fc11d8e030248eb6f70 (diff)
downloadeda-rdf-7ec05971895a0428c9912a930d789ec7bf004a32.tar.gz
eda-rdf-7ec05971895a0428c9912a930d789ec7bf004a32.tar.bz2
eda-rdf-7ec05971895a0428c9912a930d789ec7bf004a32.tar.xz
eda-rdf-7ec05971895a0428c9912a930d789ec7bf004a32.zip
o Don't to Graph.commit() unless this is an updateable SPARQL store.
-rw-r--r--trygvis/eda/__main__.py2
-rw-r--r--trygvis/eda/cli/__init__.py7
-rwxr-xr-xtrygvis/eda/cli/db_stats.py2
-rw-r--r--trygvis/eda/cli/eda_rdf.py7
4 files changed, 11 insertions, 7 deletions
diff --git a/trygvis/eda/__main__.py b/trygvis/eda/__main__.py
index 5f641d8..66ee393 100644
--- a/trygvis/eda/__main__.py
+++ b/trygvis/eda/__main__.py
@@ -1,3 +1,3 @@
-from .cli import eda_rdf
+from trygvis.eda.cli import eda_rdf
eda_rdf.main()
diff --git a/trygvis/eda/cli/__init__.py b/trygvis/eda/cli/__init__.py
index 04de836..69905cd 100644
--- a/trygvis/eda/cli/__init__.py
+++ b/trygvis/eda/cli/__init__.py
@@ -45,12 +45,12 @@ def with_database(tx):
raise CliException("The database is corrupt: %s" % path)
elif db_type == 'sparql':
query_endpoint = config["db"]["url"]
- update_endpoint = config["db"]["update_url"]
- if update_endpoint is None:
+ if not hasattr(config["db"], "update_url") is None:
g = sparqlstore.SPARQLStore()
g.open(query_endpoint)
else:
+ update_endpoint = config["db"]["update_url"]
# def my_bnode_ext(node):
# if isinstance(node, BNode):
# return '<bnode:b%s>' % node
@@ -64,7 +64,8 @@ def with_database(tx):
try:
print("g=%s" % g)
tx(g)
- g.commit()
+ if isinstance(g, sparqlstore.SPARQLUpdateStore):
+ g.commit()
finally:
g.close()
diff --git a/trygvis/eda/cli/db_stats.py b/trygvis/eda/cli/db_stats.py
index 5261ed1..aabc46a 100755
--- a/trygvis/eda/cli/db_stats.py
+++ b/trygvis/eda/cli/db_stats.py
@@ -35,6 +35,6 @@ ORDER BY ?dk_part_number
""")
cli.info("Found %d Digi-Key parts:" % len(res))
for row in res:
- cli.info(" %-30s: %s" % (row.dk_part_number, row.label))
+ cli.info(" %-30s %s" % (row.dk_part_number, row.label))
cli.with_database(db_stats)
diff --git a/trygvis/eda/cli/eda_rdf.py b/trygvis/eda/cli/eda_rdf.py
index ecd4ba6..7b4ed2c 100644
--- a/trygvis/eda/cli/eda_rdf.py
+++ b/trygvis/eda/cli/eda_rdf.py
@@ -63,7 +63,8 @@ class DigikeyDownloadForSchematic(CliCommand):
class DigikeyDownloadMetadata(CliCommand):
def __init__(self):
- super().__init__("digikey-download-metadata", "Download category tree and attribute types and values from digikey.com")
+ super().__init__("digikey-download-metadata",
+ "Download category tree and attribute types and values from digikey.com")
def run(self, argv):
p = argparse.ArgumentParser(prog=self.key, description=self.description)
@@ -76,7 +77,8 @@ class DigikeyDownloadMetadata(CliCommand):
class DigikeyDownloadAttributeTypesForCategory(CliCommand):
def __init__(self):
- super().__init__("digikey-download-attribute-types-for-category", "Download the attribute types for a category from digikey.com")
+ super().__init__("digikey-download-attribute-types-for-category",
+ "Download the attribute types for a category from digikey.com")
def run(self, argv):
p = argparse.ArgumentParser(prog=self.key, description=self.description)
@@ -88,6 +90,7 @@ class DigikeyDownloadAttributeTypesForCategory(CliCommand):
from trygvis.eda.cli import digikey_download_attribute_types_for_category
digikey_download_attribute_types_for_category.run(args.category, args.sub_category, args.output, args)
+
class MakeBom(CliCommand):
def __init__(self):
super().__init__("make-bom", "Create a BOM for a project with all info for each part.")