From ea4adcfc99e54f76df37665e1cfe904c6bb102f1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 4 Nov 2011 16:42:35 +0000 Subject: Call lv2specgen as a module rather than spawning a new process. This significantly speeds up overall runtime of gendoc.py. --- lv2specgen/lv2specgen.py | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'lv2specgen/lv2specgen.py') 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 += ', %s' % (header, header) - #other_files += '
  • Ontology %s
  • \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) -- cgit v1.2.1