annotate abcfield.py @ 316:eedf65564226

Add --index parameter to allow selection of nth occurence of field.
author Jim Hague <jim.hague@acm.org>
date Tue, 16 Jul 2013 16:25:30 +0100
parents 295ba8275ab4
children 27f29e8aafea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
1 #!/usr/bin/env python
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
2 #
122
295ba8275ab4 Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents: 110
diff changeset
3 # Extact a text field (title, by default) from a .abc file, and print it out
295ba8275ab4 Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents: 110
diff changeset
4 # formatted for use in LaTeX or HTML.
110
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
5 #
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
6
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
7 import optparse
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
8 import sys
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
9
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
10 accentedletters = {
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
11 # Acute accents
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
12 "'A" : ("&Aacute;", "\\'{A}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
13 "'E" : ("&Eacute;", "\\'{E}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
14 "'I" : ("&Iacute;", "\\'{I}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
15 "'O" : ("&Oacute;", "\\'{O}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
16 "'U" : ("&Uacute;", "\\'{U}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
17 "'Y" : ("&Yacute;", "\\'{Y}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
18 "'a" : ("&aacute;", "\\'{a}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
19 "'e" : ("&eacute;", "\\'{e}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
20 "'i" : ("&iacute;", "\\'{i}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
21 "'o" : ("&oacute;", "\\'{o}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
22 "'u" : ("&uacute;", "\\'{u}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
23 "'y" : ("&yacute;", "\\'{y}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
24
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
25 # Grave accents
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
26 "`A" : ("&Agrave;", "\\`{A}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
27 "`E" : ("&Egrave;", "\\`{E}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
28 "`I" : ("&Igrave;", "\\`{I}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
29 "`O" : ("&Ograve;", "\\`{O}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
30 "`U" : ("&Ugrave;", "\\`{U}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
31 "`a" : ("&agrave;", "\\`{a}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
32 "`e" : ("&egrave;", "\\`{e}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
33 "`i" : ("&igrave;", "\\`{i}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
34 "`o" : ("&ograve;", "\\`{o}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
35 "`u" : ("&ugrave;", "\\`{u}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
36
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
37 # Umlauts
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
38 "\"A" : ("&Auml;", "\\\"{A}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
39 "\"E" : ("&Euml;", "\\\"{E}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
40 "\"I" : ("&Iuml;", "\\\"{I}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
41 "\"O" : ("&Ouml;", "\\\"{O}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
42 "\"U" : ("&Uuml;", "\\\"{U}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
43 "\"Y" : ("&Yuml;", "\\\"{Y}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
44 "\"a" : ("&auml;", "\\\"{a}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
45 "\"e" : ("&euml;", "\\\"{e}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
46 "\"i" : ("&iuml;", "\\\"{\i}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
47 "\"o" : ("&ouml;", "\\\"{o}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
48 "\"u" : ("&uuml;", "\\\"{u}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
49 "\"y" : ("&yuml;", "\\\"{y}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
50
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
51 # Circumflexes
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
52 "^A" : ("&Acirc;", "\\^{A}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
53 "^E" : ("&Ecirc;", "\\^{E}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
54 "^I" : ("&Icirc;", "\\^{I}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
55 "^O" : ("&Ocirc;", "\\^{O}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
56 "^U" : ("&Ucirc;", "\\^{U}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
57 "^a" : ("&acirc;", "\\^{a}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
58 "^e" : ("&ecirc;", "\\^{e}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
59 "^i" : ("&icirc;", "\\^{\i}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
60 "^o" : ("&ocirc;", "\\^{o}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
61 "^u" : ("&ucirc;", "\\^{u}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
62
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
63 # Tilde
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
64 "~A" : ("&Atilde;", "\\~{A}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
65 "~N" : ("&Ntilde;", "\\~{N}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
66 "~O" : ("&Otilde;", "\\~{O}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
67 "~a" : ("&atilde;", "\\~{a}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
68 "~n" : ("&ntilde;", "\\~{n}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
69 "~o" : ("&otilde;", "\\~{o}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
70
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
71 # Cedilla
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
72 ",C" : ("&Ccedil;", "\\c{C}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
73 ",c" : ("&ccedil;", "\\c{c}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
74
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
75 # Slash
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
76 "/O" : ("&Oslash;", "\\O"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
77 "/o" : ("&oslash;", "\\o"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
78
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
79 # Ring
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
80 "AA" : ("&Aring;", "\\r{A}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
81 "aa" : ("&aring;", "\\r{a}"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
82
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
83 # Ligatures
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
84 "AE" : ("&AElig;", "\\AE"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
85 "ae" : ("&aelig;", "\\ae"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
86 "ss" : ("&szlig;", "\\ss"),
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
87 }
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
88
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
89 def convertTitle(t, options):
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
90 res = ""
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
91 while True:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
92 p = t.partition('\\')
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
93 res += p[0]
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
94 if p[1] == "":
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
95 break
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
96 abc = p[2][0:2]
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
97 t = p[2][2:]
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
98 if (options.html or options.latex) and abc in accentedletters:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
99 if options.html:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
100 res += accentedletters[abc][0]
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
101 else:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
102 res += accentedletters[abc][1]
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
103 else:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
104 res += "\\" + abc
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
105 return res
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
106
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
107 def process(inf, options):
316
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
108 n = options.index
110
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
109 for line in inf:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
110 line = line.strip()
122
295ba8275ab4 Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents: 110
diff changeset
111 if len(line) > 2 and line[0] == options.field and line[1] == ':':
316
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
112 if n > 1:
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
113 n = n - 1
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
114 else:
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
115 print(convertTitle(line[2:].strip(), options))
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
116 break
110
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
117
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
118 parser = optparse.OptionParser(usage="usage: %prog [options] [filename]\n\n"
122
295ba8275ab4 Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents: 110
diff changeset
119 " Extract field data from ABC file.")
295ba8275ab4 Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents: 110
diff changeset
120 parser.add_option("-f", "--field", dest="field", default="T",
295ba8275ab4 Make output larger where possible.
Jim Hague <jim.hague@laicatc.com>
parents: 110
diff changeset
121 help="extract the field FIELD", metavar="FIELD")
110
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
122 parser.add_option("-m", "--html", dest="html",
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
123 action="store_true", default=False,
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
124 help="format output for HTML")
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
125 parser.add_option("-l", "--latex", dest="latex",
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
126 action="store_true", default=False,
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
127 help="format ouput for LaTeX")
316
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
128 parser.add_option("-n", "--index", dest="index",
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
129 action="store", type="int", default=1,
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
130 help="report INDEXth value [default: %default]",
eedf65564226 Add --index parameter to allow selection of nth occurence of field.
Jim Hague <jim.hague@acm.org>
parents: 122
diff changeset
131 metavar="INDEX")
110
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
132 (options, args) = parser.parse_args()
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
133
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
134 if options.html and options.latex:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
135 sys.exit("You must choose one of HTML or LaTeX output")
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
136
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
137 if len(args) > 0:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
138 for arg in args:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
139 try:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
140 inf = open(arg, "r")
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
141 process(inf, options)
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
142 finally:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
143 inf.close()
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
144 else:
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
145 process(sys.stdin, options)
a63e39fc3410 Add basic diacritic handling for LaTeX and web.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
146 sys.exit(0)