diff options
-rwxr-xr-x | gendoc.py | 32 | ||||
-rwxr-xr-x | lv2specgen/lv2specgen.py | 33 |
2 files changed, 37 insertions, 28 deletions
@@ -32,9 +32,9 @@ TAGFILE = './doclinks' devnull = open(os.devnull, 'w') # Generate code (headers) documentation -print "** Generating header documentation" +print('** Generating header documentation') #shutil.copy('Doxyfile', os.path.join('upload', 'Doxyfile')) -print ' * Calling doxygen in ' + os.getcwd() +print(' * Calling doxygen in ' + os.getcwd()) subprocess.call('doxygen', stdout=devnull) @@ -76,7 +76,7 @@ for cn in root.childNodes: mafile, manchor)) bettertags.close() -print '** Generating core documentation' +print('** Generating core documentation') lv2_outdir = os.path.join(out_base, 'lv2core') os.mkdir(lv2_outdir) @@ -101,7 +101,7 @@ footer = open('./lv2specgen/footer.html', 'r') # Generate main (ontology) documentation and indices for dir in ['ext', 'extensions']: - print "** Generating %s%s documentation" % (URIPREFIX, dir) + print("** Generating %s%s documentation" % (URIPREFIX, dir)) outdir = os.path.join(out_base, dir) @@ -127,16 +127,18 @@ for dir in ['ext', 'extensions']: b = b[b.find('/') + 1:] # Get extension URI - ext = subprocess.Popen(['roqet', '-q', '-e', """ + ext = str(subprocess.Popen(['roqet', '-q', '-e', """ PREFIX lv2: <http://lv2plug.in/ns/lv2core#> SELECT ?ext FROM <%s.lv2/%s.ttl> WHERE { ?ext a lv2:Specification } -""" % (os.path.join(dir, b), b)], stdout=subprocess.PIPE).communicate()[0] +""" % (os.path.join(dir, b), b)], stdout=subprocess.PIPE).communicate()[0]) if ext == "": continue - ext = re.sub('^result: \[ext=uri<', '', ext) - ext = re.sub('>\]$', '', ext).strip() + ext = re.sub("^b'", '', ext) + ext = re.sub("\n'$", '', ext) + ext = re.sub('.*result: \[ext=uri<', '', ext) + ext = re.sub('>.*$', '', ext).strip() # Get revision query = """ @@ -145,12 +147,14 @@ PREFIX doap: <http://usefulinc.com/ns/doap#> SELECT ?rev FROM <%s.lv2/%s.ttl> WHERE { <%s> doap:release [ doap:revision ?rev ] } """ % (os.path.join(dir, b), b, ext) - rev = subprocess.Popen(['roqet', '-q', '-e', query], - stdout=subprocess.PIPE).communicate()[0] + rev = str(subprocess.Popen(['roqet', '-q', '-e', query], + stdout=subprocess.PIPE).communicate()[0]) if rev != '': - rev = re.sub('^result: \[rev=string\("', '', rev) - rev = re.sub('"\)\]$', '', rev).strip() + rev = re.sub("^b'", '', rev) + rev = re.sub("\n'$", '', rev) + rev = re.sub('.*result: \[rev=string\("', '', rev) + rev = re.sub('"\)\].*$', '', rev).strip() else: rev = '0' @@ -168,7 +172,7 @@ SELECT ?rev FROM <%s.lv2/%s.ttl> WHERE { <%s> doap:release [ doap:revision ?rev specgendir = '../../../lv2specgen/' if (os.access(outdir + '/%s.lv2/%s.ttl' % (b, b), os.R_OK)): - print ' * Calling lv2specgen for %s%s/%s' %(URIPREFIX, dir, b) + print(' * Calling lv2specgen for %s%s/%s' %(URIPREFIX, dir, b)) subprocess.call([specgendir + 'lv2specgen.py', '%s.lv2/%s.ttl' % (b, b), specgendir + 'template.html', @@ -206,7 +210,7 @@ SELECT ?rev FROM <%s.lv2/%s.ttl> WHERE { <%s> doap:release [ doap:revision ?rev index_html += '</body></html>\n' index_file = open(os.path.join(outdir, 'index.html'), 'w') - print >>index_file, index_html + index_file.write(index_html) index_file.close() # Copy stylesheet diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 3bbdfcc..06c983b 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -784,11 +784,13 @@ def specgen(specloc, docdir, template, doclinks, instances=False, mode="spec"): p = RDF.Parser(name="guess") p.parse_into_model(m, specloc) - except IOError, e: - print "Error reading from ontology:", str(e) + except IOError: + e = sys.exc_info()[1] + print('Error reading from ontology:' + str(e)) usage() - except RDF.RedlandError, e: - print "Error parsing the ontology" + except RDF.RedlandError: + e = sys.exc_info()[1] + print('Error parsing the ontology') spec_url = getOntologyNS(m) @@ -810,7 +812,7 @@ def specgen(specloc, docdir, template, doclinks, instances=False, mode="spec"): prefixes_html += "</span>" if spec_pre is None: - print 'No namespace prefix for specification defined' + print('No namespace prefix for specification defined') sys.exit(1) ns_list[spec_ns_str] = spec_pre @@ -839,7 +841,7 @@ def specgen(specloc, docdir, template, doclinks, instances=False, mode="spec"): rdfdata = re.sub(r"(<!DOCTYPE[^]]*]>)", "", rdfdata) #rdfdata.replace("""<?xml version="1.0"?>""", "") - # print template % (azlist.encode("utf-8"), termlist.encode("utf-8"), rdfdata.encode("ISO-8859-1")) + # print(template % (azlist.encode("utf-8"), termlist.encode("utf-8"), rdfdata.encode("ISO-8859-1"))) template = re.sub(r"^#format \w*\n", "", template) template = re.sub(r"\$VersionInfo\$", owlVersionInfo(m).encode("utf-8"), template) @@ -919,8 +921,9 @@ def save(path, text): f.write(text) f.flush() f.close() - except Exception, e: - print "Error writing to file \"" + path + "\": " + str(e) + except Exception: + e = sys.exc_info()[1] + print('Error writing to file "' + path + '": ' + str(e)) def getNamespaces(parser): @@ -954,7 +957,7 @@ def getOntologyNS(m): def usage(): script = os.path.basename(sys.argv[0]) - print """Usage: %s ONTOLOGY TEMPLATE STYLE OUTPUT [FLAGS] + print("""Usage: %s ONTOLOGY TEMPLATE STYLE OUTPUT [FLAGS] ONTOLOGY : Path to ontology file TEMPLATE : HTML template path @@ -968,7 +971,7 @@ def usage(): Example: %s lv2_foos.ttl template.html style.css lv2_foos.html ../doc -i -p foos -""" % (script, script) +""" % (script, script)) sys.exit(-1) @@ -989,8 +992,9 @@ if __name__ == "__main__": try: f = open(temploc, "r") template = f.read() - except Exception, e: - print "Error reading from template \"" + temploc + "\": " + str(e) + except Exception: + e = sys.exc_info()[1] + print("Error reading from template \"" + temploc + "\": " + str(e)) usage() # Footer @@ -999,8 +1003,9 @@ if __name__ == "__main__": try: f = open(footerloc, "r") footer = f.read() - except Exception, e: - print "Error reading from footer \"" + footerloc + "\": " + str(e) + except Exception: + e = sys.exc_info()[1] + print("Error reading from footer \"" + footerloc + "\": " + str(e)) usage() template = template.replace('@FOOTER@', footer) |