lilypond-1.3.65
[lilypond.git] / buildscripts / html-accents.py
blob228ed7485fdc793a6efeadc9b3633cf7bd307f0c
1 #!@PYTHON@
3 # html-accents.py -- convert (some) latin1 chars to html
4 # pod2html is so broken...
5 #
6 # source file of the GNU LilyPond music typesetter
7 #
8 # (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
10 name = 'html-accents'
11 version = '0.1'
13 import os
14 import sys
15 sys.path.append ('@abs-step-bindir@')
16 sys.path.append (os.environ['HOME'] + '/usr/src/lilypond/stepmake/bin')
18 import getopt
19 from string import *
20 import regex
21 import regsub
22 import time
24 def program_id ():
25 return name + ' version ' + version;
27 def identify ():
28 sys.stdout.write (program_id () + '\n')
30 def help ():
31 sys.stdout.write ("Usage: " + name + " [options] INFILE OUTFILE\n"
32 + "Convert (some) latin1 chars to html &xxx;\n\n"
33 + "Options:\n"
34 + " -h, --help print this help\n"
35 + " -p, --package=DIR specify package\n"
37 sys.exit (0)
39 # chars = {'è':'&egrave;', }
40 chars = {
41 'á':'&aacute;',
42 'â':'&acirc;',
43 'æ':'&aelig;',
44 'à':'&agrave;',
45 'å':'&aring;',
46 'ã':'&atilde;',
47 'ä':'&auml;',
49 'ç':'&ccedil;',
51 'é':'&eacute;',
52 'ê':'&ecirc;',
53 'è':'&egrave;',
54 'ë':'&euml;',
56 'í':'&iacute;',
57 'î':'&icirc;',
58 'ì':'&igrave;',
59 'ï':'&iuml;',
61 'ñ':'&ntilde;',
63 'ó':'&oacute;',
64 'ô':'&ocirc;',
65 'ò':'&ograve;',
66 'ø':'&oslash;',
67 'õ':'&otilde;',
68 'ö':'&ouml;',
70 'ú':'&uacute;',
71 'û':'&ucirc;',
72 'ù':'&ugrave;',
73 'ü':'&uuml;'
76 def convert_accents (inname, outname):
77 from flower import *
78 text = File (inname)
79 # ugh
80 html = File (outname, 'w')
82 while not text.eof ():
83 line = text.readline ()
84 for i in chars.keys ():
85 line = regsub.gsub (i, chars[i], line)
86 html.write (line)
87 text.close ()
88 html.close ()
90 def main ():
91 identify ()
92 (options, files) = getopt.getopt (
93 sys.argv[1:], 'hp:', ['help', 'package='])
94 for opt in options:
95 o = opt[0]
96 a = opt[1]
97 if o== '--help' or o == '-h':
98 help ()
99 elif o == '-p' or o == '--package':
100 topdir = a
101 else:
102 print o
103 raise getopt.error
105 sys.path.append (topdir + '/stepmake/bin')
106 from packagepython import *
107 package = Package (topdir)
108 packager = Packager ()
110 from flower import *
112 convert_accents (files[0], files[1])
114 main ()