]> www.ginac.de Git - ginac.git/blob - scripts/fixupind.py
G_do_hoelder: fix case with real x values which are not of type cl_R.
[ginac.git] / scripts / fixupind.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # TeX Live 2012 seems to dislike files produces by doxygen (1.8.x.y)
4 # In particular, makeindex(1) program creates invalid index entries like
5 # \hyperpage{NNN_}
6 # (note the trailing underscore in the page number). This breaks automatic
7 # builds and is very annoying. Hence this script. It replaces (broken)
8 # \hyperpage{NNN_} with \hyperpage{NNN}.
9 # Note: this is an ugly work around, a proper fix is welcome.
10 import sys, os, re
11
12 def fixupind(fname):
13         """ Fix \\hyperpage{NNN_} entries in the ind file @var{fname} """
14         tmpout = fname + '.tmp' 
15         inp = open(fname)
16         out = open(tmpout, 'wt')
17         rx = re.compile('(hyperpage)[{]([0-9]+)[_][}]')
18         for line in inp:
19                 out.write(re.sub(rx, '\\1{\\2}', line))
20         out.flush()
21         out.close()
22         inp.close()
23         os.rename(tmpout, fname)
24
25 if __name__ == '__main__':
26         if len(sys.argv) <= 1:
27                 sys.exit(1)
28         fixupind(sys.argv[1])
29         sys.exit(0)
30