Changeset 2099

Show
Ignore:
Timestamp:
06/13/09 07:37:01 (15 months ago)
Author:
drobilla
Message:

Emit spec description (rdfs:comment).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lv2specgen/lv2specgen.py

    r2098 r2099  
    7777            "http://www.w3.org/2003/01/geo/wgs84_pos#"      : "geo", 
    7878            "http://www.w3.org/2004/02/skos/core#"          : "skos", 
    79             "http://lv2plug.in/ns/lv2core#"                 : "lv2" 
     79            "http://lv2plug.in/ns/lv2core#"                 : "lv2", 
     80            "http://usefulinc.com/ns/doap#"                 : "doap" 
    8081          } 
    8182 
     
    8586vs = RDF.NS('http://www.w3.org/2003/06/sw-vocab-status/ns#') 
    8687lv2 = RDF.NS('http://lv2plug.in/ns/lv2core#') 
     88doap = RDF.NS('http://usefulinc.com/ns/doap#') 
    8789 
    8890termdir = './doc' #TODO 
     
    368370                curie = "%s:%s" % (nspre, t) 
    369371         
    370         doc += """<div class="specterm" id="term_%s">\n<h3>%s: %s</h3>\n""" % (t, category, curie) 
    371372        try: 
    372373            term_uri = term.uri 
    373374        except: 
    374375            term_uri = term 
    375         doc += """<p style="font-family:monospace; font-size:0.em;">URI: <a href="%s">%s</a></p>""" % (term_uri, term_uri) 
     376         
     377        doc += """<div class="specterm" id="term_%s">\n<h3>%s: <a href="%s">%s</a></h3>\n""" % (t, category, term_uri, curie) 
     378 
    376379        label, comment = get_rdfs(m, term)     
    377380        status = get_status(m, term) 
     
    522525    return classlist, proplist 
    523526 
     527def specProperty(m, subject, predicate): 
     528    "Return the rdfs:comment of the spec." 
     529    for c in m.find_statements(RDF.Statement(None, predicate, None)): 
     530        if str(c.subject.uri) == str(subject): 
     531            return str(c.object) 
     532    return '' 
     533 
    524534def getInstances(model, classes, properties): 
    525535    """ 
     
    608618        (os.path.basename(specloc), os.path.basename(sys.argv[0]), time.strftime('%X %x %Z'))) 
    609619 
    610     template = template.replace('@NAME@', 'LV2 Port Groups') 
     620    template = template.replace('@NAME@', specProperty(m, spec_url, doap.name)) 
    611621    template = template.replace('@URI@', spec_url) 
    612622    template = template.replace('@PREFIX@', spec_pre) 
     
    614624    template = template.replace('@FILENAME@', os.path.basename(specloc)) 
    615625    template = template.replace('@MAIL@', 'devel@lists.lv2plug.in') 
     626    template = template.replace('@COMMENT@', specProperty(m, spec_url, rdfs.comment)) 
    616627     
    617628    return template