diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-12-27 22:49:58 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-12-27 22:49:58 +0100 |
commit | 8af35183f1f25e2f9d1d111cac85a48622f22673 (patch) | |
tree | 0b7ed75ff502742196508645323d265fc264ad4f /trygvis/eda/cli/add_to_db.py | |
parent | 9bf18900c05547a40bb3c3a7a819a137e81dae92 (diff) | |
download | eda-rdf-8af35183f1f25e2f9d1d111cac85a48622f22673.tar.gz eda-rdf-8af35183f1f25e2f9d1d111cac85a48622f22673.tar.bz2 eda-rdf-8af35183f1f25e2f9d1d111cac85a48622f22673.tar.xz eda-rdf-8af35183f1f25e2f9d1d111cac85a48622f22673.zip |
o Replacing open_database with with_database to make sure it is closed after use.
Diffstat (limited to 'trygvis/eda/cli/add_to_db.py')
-rw-r--r-- | trygvis/eda/cli/add_to_db.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/trygvis/eda/cli/add_to_db.py b/trygvis/eda/cli/add_to_db.py index 0511850..e3b07c1 100644 --- a/trygvis/eda/cli/add_to_db.py +++ b/trygvis/eda/cli/add_to_db.py @@ -2,16 +2,17 @@ import trygvis.eda.cli as cli def run(files, path, args): - g = cli.open_database(path) + def load(g): + s = 0 + for f in files: + cli.info("Adding %s" % f) + pre = len(g) + g.load(f, format="turtle") + post = len(g) + diff = post - pre + s += diff + cli.info("Loaded %d tuples" % diff) - s = 0 - for f in files: - cli.info("Adding %s" % f) - pre = len(g) - g.load(f, format="turtle") - post = len(g) - diff = post - pre - s += diff - cli.info("Loaded %d tuples" % diff) + cli.info("Done. Loaded %d tuples" % s) - cli.info("Done. Loaded %d tuples" % s) + cli.with_database(path, load) |