From b73784ea11af64f1e655637aa2012f454748a87f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 9 Jan 2013 01:17:56 +0000 Subject: Fix lv2specgen usage from command line. Fix round-trip UTF-8 support in lv2specgen. Support specifications with URI equivalent to prefix and/or slash namespaces. --- lv2specgen/lv2specgen.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lv2specgen/lv2specgen.py') diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 28a84db..efa5c60 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -1092,7 +1092,9 @@ def specgen(specloc, indir, style_uri, docdir, tags, instances=False, offline=Fa if uri.startswith('file:'): continue; ns_list[str(uri)] = i - if str(uri) == spec_url + '#': + if (str(uri) == spec_url + '#' or + str(uri) == spec_url + '/' or + str(uri) == spec_url): spec_pre = i prefixes_html += '%s ' % (uri, i) prefixes_html += "" @@ -1137,7 +1139,7 @@ def specgen(specloc, indir, style_uri, docdir, tags, instances=False, offline=Fa template = template.replace('@BASE@', spec_ns_str) template = template.replace('@AUTHORS@', specAuthors(m, spec)) template = template.replace('@INDEX@', azlist) - template = template.replace('@REFERENCE@', termlist.encode("utf-8")) + template = template.replace('@REFERENCE@', termlist) template = template.replace('@FILENAME@', filename) template = template.replace('@HEADER@', basename + '.h') template = template.replace('@MAIL@', 'devel@lists.lv2plug.in') @@ -1204,7 +1206,7 @@ def specgen(specloc, indir, style_uri, docdir, tags, instances=False, offline=Fa def save(path, text): try: f = open(path, "w") - f.write(text) + f.write(text.encode("utf-8")) f.flush() f.close() except Exception: @@ -1286,7 +1288,7 @@ if __name__ == "__main__": i += 1 try: - save(output, specgen(specloc, indir, style, docdir, tags, instances=instances)) + save(output, specgen(ontology, indir, style, docdir, tags, instances=instances)) except: e = sys.exc_info()[1] print('error: ' + str(e)) -- cgit v1.2.1