/
fixindex.py
42 lines (35 loc) · 1.16 KB
/
fixindex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
try:
from indextools import processfile
except ImportError:
from langsci.indextools import processfile
if __name__ == "__main__":
"""
Transform a file main._dx into mainmod._dx, where the underscore represents an index type given in the argument.
Index types are:
a: author index
s: subject index
l: language index
Examples:
> python3 fixindex.py
fixes the author index only. Read: main.adx. Write: mainmod.adx
> python3 fixindex.py a
fixes the author index only. Read: main.adx. Write: mainmod.adx
> python3 fixindex.py l
fixes the language index only. Read: main.ldx. Write: mainmod.ldx
> python3 fixindex.py lsa
fixes all three index types. Read: main.adx, main.ldx, main.sdx. Write: mainmod.adx, mainmod.ldx, mainmod.sdx
"""
# indextypes = "a"
# try:
# indextypes = sys.argv[1]
# except IndexError:
# pass
# for indextype in indextypes:
# processfile("main.%sdx" % indextype)
filename = 'main.adx'
try:
filename = sys.argv[1]
except IndexError:
print("no filename given. Default is main.adx")
processfile(filename)