aboutsummaryrefslogtreecommitdiffstats
path: root/lv2include/lv2include.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-10-20 18:31:12 +0000
committerDavid Robillard <d@drobilla.net>2010-10-20 18:31:12 +0000
commit2be75b8d22dedbc2b2d011700659552def2bc72b (patch)
tree35807cf150dc14de588ffc031303d67e0a5e7899 /lv2include/lv2include.py
parent3bef9fa0deec36b00941f9777f66f48c48eafe77 (diff)
downloadlv2-2be75b8d22dedbc2b2d011700659552def2bc72b.tar.xz
Abstract all RDF stuff into 3 functions.
Diffstat (limited to 'lv2include/lv2include.py')
-rwxr-xr-xlv2include/lv2include.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/lv2include/lv2include.py b/lv2include/lv2include.py
index 8786411..f4b9b3c 100755
--- a/lv2include/lv2include.py
+++ b/lv2include/lv2include.py
@@ -34,8 +34,20 @@ import sys
import RDF
-rdf = RDF.NS('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
-lv2 = RDF.NS('http://lv2plug.in/ns/lv2core#')
+def rdf_load(uri):
+ model = RDF.Model()
+ parser = RDF.Parser(name="guess")
+ parser.parse_into_model(model, uri)
+ return model
+
+def rdf_find(model, s, p, o):
+ return model.find_statements(RDF.Statement(s, p, o))
+
+def rdf_namespace(uri):
+ return RDF.NS(uri)
+
+rdf = rdf_namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
+lv2 = rdf_namespace('http://lv2plug.in/ns/lv2core#')
def lv2_path():
"Return the LV2 search path (LV2_PATH in the environment, or a default)."
@@ -81,12 +93,10 @@ def build_tree(search_path, outdir):
the extension URIs."""
for bundle in __bundles(search_path):
# Load manifest into model
- manifest = RDF.Model()
- parser = RDF.Parser(name="guess")
- parser.parse_into_model(manifest, 'file://' + os.path.join(bundle, 'manifest.ttl'))
+ manifest = rdf_load('file://' + os.path.join(bundle, 'manifest.ttl'))
# Query extension URI
- results = manifest.find_statements(RDF.Statement(None, rdf.type, lv2.Specification))
+ results = rdf_find(manifest, None, rdf.type, lv2.Specification)
for r in results:
ext_uri = str(r.subject.uri)
ext_scheme = ext_uri[0:ext_uri.find(':')]