X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Ftexi2omf.py;h=cc2603f5e03e172b7fb9d130636ea12d461d318d;hb=2d650ae52cffbca4ce06075107804e01707ea8b4;hp=0bb7c197b25b5054f7435bc103b5eff0218778af;hpb=73799bf2e0b40908340b4bee5eb0d3949ca1082d;p=lilypond.git diff --git a/buildscripts/texi2omf.py b/buildscripts/texi2omf.py index 0bb7c197b2..cc2603f5e0 100644 --- a/buildscripts/texi2omf.py +++ b/buildscripts/texi2omf.py @@ -7,7 +7,7 @@ import sys import time def usage (): - sys.stderr.write (''' + sys.stderr.write (''' texi2omf [options] FILE.texi > FILE.omf Options: @@ -26,9 +26,9 @@ etc. ''') - + (options, files) = getopt.getopt (sys.argv[1:], '', - ['format=', 'location=', 'version=']) + ['format=', 'location=', 'version=']) license = 'FDL' location = '' @@ -38,32 +38,32 @@ name = os.getenv ('USERNAME') format = 'xml' for (o, a) in options: - if o == '--format': - format = a - elif o == '--location': - location = 'file:%s' % a - elif o == '--version': - version = a - else: - assert 0 - - + if o == '--format': + format = a + elif o == '--location': + location = 'file:%s' % a + elif o == '--version': + version = a + else: + assert 0 + + if not files: - usage () - sys.exit (2) + usage () + sys.exit (2) formats = { - 'html' : 'text/html', - 'pdf' : 'application/pdf', - 'ps.gz' : 'application/postscript', - 'ps' : 'application/postscript', - 'xml' : 'text/xml', - } + 'html' : 'text/html', + 'pdf' : 'application/pdf', + 'ps.gz' : 'application/postscript', + 'ps' : 'application/postscript', + 'xml' : 'text/xml', + } if not formats.has_key (format): - sys.stderr.write ("Format `%s' unknown\n" % format) - sys.exit (1) + sys.stderr.write ("Format `%s' unknown\n" % format) + sys.exit (1) infile = files[0] @@ -73,80 +73,80 @@ today = time.localtime () texi = open (infile).read () if not location: - location = 'file:/%s' % re.sub (r'\..*', '.' + format, infile) + location = 'file:/%s' % re.sub (r'\..*', '.' + format, infile) omf_vars = { - 'date': '%d-%d-%d' % today[:3], - 'mimeformat': formats[format], - 'maintainer': "%s (%s)" % (name, email), - 'version' : version, - 'location' : location, - 'language' : 'C', - } + 'date': '%d-%d-%d' % today[:3], + 'mimeformat': formats[format], + 'maintainer': "%s (%s)" % (name, email), + 'version' : version, + 'location' : location, + 'language' : 'C', + } omf_caterories = ['subject', 'creator', 'maintainer', 'contributor', - 'title', 'subtitle', 'version', 'category', 'type', - 'description', 'license', 'language',] - + 'title', 'subtitle', 'version', 'category', 'type', + 'description', 'license', 'language',] + for a in omf_caterories: - m = re.search ('@omf%s (.*)\n'% a, texi) - if m: - omf_vars[a] = m.group (1) - elif not omf_vars.has_key (a): - omf_vars[a] = '' - + m = re.search ('@omf%s (.*)\n'% a, texi) + if m: + omf_vars[a] = m.group (1) + elif not omf_vars.has_key (a): + omf_vars[a] = '' + if not omf_vars['title']: - title = '' - m = re.search ('@title (.*)\n', texi) - if m: - title = m.group (1) + title = '' + m = re.search ('@title (.*)\n', texi) + if m: + title = m.group (1) - subtitle = '' - m = re.search ('@subtitle (.*)\n', texi) - if m: - subtitle = m.group (1) + subtitle = '' + m = re.search ('@subtitle (.*)\n', texi) + if m: + subtitle = m.group (1) - if subtitle: - title = '%s -- %s' % (title, subtitle) + if subtitle: + title = '%s -- %s' % (title, subtitle) - omf_vars['title'] = title - + omf_vars['title'] = title + if not omf_vars['creator']: - m = re.search ('@author (.*)\n', texi) - if m: - omf_vars['creator'] = m.group (1) + m = re.search ('@author (.*)\n', texi) + if m: + omf_vars['creator'] = m.group (1) print r''' - - - %(creator)s - - - %(maintainer)s - - - %(title)s - - - %(date)s - - - - - %(description)s - - - %(type)s - - - - - - + + + %(creator)s + + + %(maintainer)s + + + %(title)s + + + %(date)s + + + + + %(description)s + + + %(type)s + + + + + + ''' % omf_vars