aboutsummaryrefslogtreecommitdiffstats
path: root/lv2specgen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-11-04 16:42:35 +0000
committerDavid Robillard <d@drobilla.net>2011-11-04 16:42:35 +0000
commitea4adcfc99e54f76df37665e1cfe904c6bb102f1 (patch)
treebd35d5dee930578c59d4314e196b730d95269edc /lv2specgen
parentd45e469b43b6ec467e458f719b0dc3b4c8c4a900 (diff)
downloadlv2-ea4adcfc99e54f76df37665e1cfe904c6bb102f1.tar.xz
Call lv2specgen as a module rather than spawning a new process.
This significantly speeds up overall runtime of gendoc.py.
Diffstat (limited to 'lv2specgen')
-rwxr-xr-xlv2specgen/lv2specgen.py40
1 files changed, 15 insertions, 25 deletions
diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py
index 949ec08..8138654 100755
--- a/lv2specgen/lv2specgen.py
+++ b/lv2specgen/lv2specgen.py
@@ -867,24 +867,14 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal
# Template
temploc = os.path.join(indir, "template.html")
template = None
- try:
- f = open(temploc, "r")
- template = f.read()
- except Exception:
- e = sys.exc_info()[1]
- print("Error reading from template \"" + temploc + "\": " + str(e))
- usage()
+ f = open(temploc, "r")
+ template = f.read()
# Footer
footerloc = os.path.join(indir, "footer.html")
footer = ''
- try:
- f = open(footerloc, "r")
- footer = f.read()
- except Exception:
- e = sys.exc_info()[1]
- print("Error reading from footer \"" + footerloc + "\": " + str(e))
- usage()
+ f = open(footerloc, "r")
+ footer = f.read()
template = template.replace('@FOOTER@', footer)
@@ -896,15 +886,10 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal
os.path.join(doc_base, url), sym)
m = rdflib.ConjunctiveGraph()
- try:
- base = specloc[0:specloc.rfind('/')]
- manifest_path = os.path.join(base, 'manifest.ttl')
- m.parse(manifest_path, format='n3')
- m.parse(specloc, format='n3')
- except:
- e = sys.exc_info()[1]
- print('Error reading ontology: ' + str(e))
- return None
+ base = specloc[0:specloc.rfind('/')]
+ manifest_path = os.path.join(base, 'manifest.ttl')
+ m.parse(manifest_path, format='n3')
+ m.parse(specloc, format='n3')
spec_url = getOntologyNS(m)
@@ -997,8 +982,6 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal
header = basename + '.h'
other_files += ', <a href="%s">%s</a>' % (header, header)
- #other_files += '<li><a href="%s">Ontology</a> %s</li>\n' % (filename, filename)
-
abs_bundle_path = os.path.abspath(bundle_path)
see_also_files = specProperties(m, spec_url, rdfs.seeAlso)
for f in see_also_files:
@@ -1122,4 +1105,11 @@ if __name__ == "__main__":
i += 1
i += 1
+ try:
save(dest, specgen(specloc, indir, docdir, style_uri, doc_base, doc_links, instances=instances))
+ except:
+ e = sys.exc_info()[1]
+ print('error: ' + str(e))
+ sys.exit(1)
+
+ sys.exit(0)