aboutsummaryrefslogtreecommitdiffstats
path: root/lv2specgen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-03-09 22:58:49 +0000
committerDavid Robillard <d@drobilla.net>2011-03-09 22:58:49 +0000
commit5922ee87b7434557ad3bfdf30e35461a51aeb91b (patch)
tree7d82362854cd481c8c1c2485019b6c536d766402 /lv2specgen
parent2b330e1b184a32bbbcd361fba17f0e7e61fa9112 (diff)
downloadlv2-5922ee87b7434557ad3bfdf30e35461a51aeb91b.tar.xz
Show types on "instance" (i.e. not spec or property) descriptions.
Fix crazy multi-parse issue.
Diffstat (limited to 'lv2specgen')
-rwxr-xr-xlv2specgen/lv2specgen.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py
index 7c7c078..9c3ab3d 100755
--- a/lv2specgen/lv2specgen.py
+++ b/lv2specgen/lv2specgen.py
@@ -351,15 +351,16 @@ def extraInfo(term,m):
def rdfsInstanceInfo(term,m):
"""Generate rdfs-type information for instances"""
doc = ""
-
- t = m.find_statements( RDF.Statement(term, rdf.type, None) )
+
+ term = RDF.Uri(term)
+ t = m.find_statements(RDF.Statement(term, rdf.type, None))
if t.current():
doc += "<dt>Type</dt>"
while t.current():
- doc += "<dd>%s</dd>" % getTermLink(str(t.current().object.uri), term, rdf.type)
+ doc += "<dd>%s</dd>" % getTermLink(RDF.Node(t.current().object), RDF.Node(term), rdf.type)
t.next()
- doc += extraInfo(term, m)
+ doc += extraInfo(RDF.Node(term), m)
return doc
@@ -641,7 +642,7 @@ def getInstances(model, classes, properties):
for one in classes:
for i in model.find_statements(RDF.Statement(None, rdf.type, spec_ns[one])):
uri = str(i.subject.uri)
- if not uri in instances:
+ if not uri in instances and uri != spec_url:
instances.append(uri)
for i in model.find_statements(RDF.Statement(None, rdf.type, None)):
if not i.subject.is_resource():
@@ -668,13 +669,15 @@ def specgen(specloc, docdir, template, instances=False, mode="spec"):
m = RDF.Model()
p = RDF.Parser(name="guess")
try:
- # Parse ontology file
- p.parse_into_model(m, specloc)
+ base = specloc[0:specloc.rfind('/')]
# Parse manifest.ttl
- base = specloc[0:specloc.rfind('/')]
manifest_path = os.path.join(base, 'manifest.ttl')
p.parse_into_model(m, manifest_path)
+
+ # Parse ontology file
+ p.parse_into_model(m, specloc)
+
except IOError, e:
print "Error reading from ontology:", str(e)
usage()