OLD | NEW |
| (Empty) |
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories. | |
2 # See LICENSE for details. | |
3 | |
4 | |
5 def setIndexFilename(filename='index.xhtml'): | |
6 global indexFilename | |
7 indexFilename = filename | |
8 | |
9 def getIndexFilename(): | |
10 global indexFilename | |
11 return indexFilename | |
12 | |
13 def addEntry(filename, anchor, text, reference): | |
14 global entries | |
15 if not entries.has_key(text): | |
16 entries[text] = [] | |
17 entries[text].append((filename, anchor, reference)) | |
18 | |
19 def clearEntries(): | |
20 global entries | |
21 entries = {} | |
22 | |
23 def generateIndex(): | |
24 global entries | |
25 global indexFilename | |
26 | |
27 if not indexFilename: | |
28 return | |
29 | |
30 f = open(indexFilename, 'w') | |
31 sortedEntries = [(e.lower(), e) for e in entries] | |
32 sortedEntries.sort() | |
33 sortedEntries = [e[1] for e in sortedEntries] | |
34 for text in sortedEntries: | |
35 refs = [] | |
36 f.write(text.replace('!', ', ') + ': ') | |
37 for (file, anchor, reference) in entries[text]: | |
38 refs.append('<a href="%s#%s">%s</a>' % (file, anchor, reference)) | |
39 if text == 'infinite recursion': | |
40 refs.append('<em>See Also:</em> recursion, infinite\n') | |
41 if text == 'recursion!infinite': | |
42 refs.append('<em>See Also:</em> infinite recursion\n') | |
43 f.write('%s<br />\n' % ", ".join(refs)) | |
44 f.close() | |
45 | |
46 def reset(): | |
47 clearEntries() | |
48 setIndexFilename() | |
49 | |
50 reset() | |
OLD | NEW |