From 4d479ac5f9083f423e79cf1a3978b3f12c76a65c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 4 Nov 2011 18:13:09 +0000 Subject: Remove terrible roqet kludges and use rdflib to find URI and version. --- gendoc.py | 56 +++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) (limited to 'gendoc.py') diff --git a/gendoc.py b/gendoc.py index 0943891..353176d 100755 --- a/gendoc.py +++ b/gendoc.py @@ -3,6 +3,7 @@ import datetime import glob import os +import rdflib import re import shutil import subprocess @@ -27,6 +28,9 @@ SPECGENDIR = './specgen' STYLEURI = os.path.join('aux', 'style.css') TAGFILE = './doclinks' +rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#') +lv2 = rdflib.Namespace('http://lv2plug.in/ns/lv2core#') + devnull = open(os.devnull, 'w') # Generate code (headers) documentation @@ -124,44 +128,26 @@ for dir in ['ext', 'extensions']: b = bundle.replace('.lv2', '') b = b[b.find('/') + 1:] - # Get extension URI - ext = str(subprocess.Popen(['roqet', '-q', '-e', """ -PREFIX lv2: -SELECT ?ext FROM <%s.lv2/%s.ttl> WHERE { ?ext a lv2:Specification } -""" % (os.path.join(dir, b), b)], stdout=subprocess.PIPE).communicate()[0]) + model = rdflib.ConjunctiveGraph() + model.parse('%s/manifest.ttl' % bundle, format='n3') + model.parse('%s/%s.ttl' % (bundle, b), format='n3') - if ext == "": + # Get extension URI + ext_node = model.value(None, rdf.type, lv2.Specification) + if not ext_node: continue - 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 = """ -PREFIX lv2: -PREFIX doap: -SELECT ?rev FROM <%s.lv2/%s.ttl> WHERE { <%s> doap:release [ doap:revision ?rev ] } -""" % (os.path.join(dir, b), b, ext) - - rev = str(subprocess.Popen(['roqet', '-q', '-e', query], - stdout=subprocess.PIPE).communicate()[0]) - - if rev != '': - 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' + ext = str(ext_node) - minor = '0' - micro = '0' - match = re.search('([^\.]*)\.([^\.]*)', rev) - if match: - minor = match.group(1) - micro = match.group(2) + # Get version + minor = 0 + micro = 0 + try: + minor = int(model.value(ext_node, lv2.minorVersion, None)) + micro = int(model.value(ext_node, lv2.microVersion, None)) + except Exception as e: + print "warning: %s: failed to find version for %s" % (bundle, ext) + pass specgendir = '../../../lv2specgen/' if (os.access(outdir + '/%s.lv2/%s.ttl' % (b, b), os.R_OK)): @@ -179,7 +165,7 @@ SELECT ?rev FROM <%s.lv2/%s.ttl> WHERE { <%s> doap:release [ doap:revision ?rev os.chdir(oldcwd) li = '
  • ' - if minor == '0' or (int(micro) % 2) != 0: + if minor == 0 or (micro % 2 != 0): li += 'Experimental: ' li += '%s' % (b, b) li += '
  • ' -- cgit v1.2.1