Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (49 sloc) 1.647 kb
46e8b0f @timf rest of main iaas from 2009-01-10
timf authored
1 #!/usr/bin/env python
2
3 # To generate index, run "generate-index.py < workspacepilot.py"
4
5 # If a section is added make sure to add a line for that in the INDEX
6 # definition in workspacepilot.py or the line numbers will be off.
7 # Not spending the time to auto replace the INDEX definition, just
8 # paste in the output.
9
10 import sys
11 begin=0
12 end=0
13 insection=False
14 namedict = {}
15 romandict = {}
16 linenumdict = {}
17 entrynum = 0
18 longestname = 0
19 longestroman = 0
20 for n,line in enumerate(sys.stdin):
21 if line.startswith("# #############################") and not insection:
22 begin = n
23 insection = True
24 if n == begin + 1:
25 name = line[2:] # strip "# "
26 name = name[:-1] # strip newline
27 idx = name.rfind(". ")
28 roman = name[:idx+1]
29 romandict[entrynum] = roman
30 if len(roman) > longestroman:
31 longestroman = len(roman)
32 name = name[idx+2:]
33 namedict[entrynum] = name
34 if len(name) > longestname:
35 longestname = len(name)
36 if insection and line.startswith("# }}} END"):
37 end = n
38 insection = False
39 linenumdict[entrynum] = "(lines %d-%d)" % (begin+1, end+1)
40 entrynum += 1
41
42 # justify right
43 for n,roman in enumerate(romandict.values()):
44 if len(roman) < longestroman:
45 diff = longestroman - len(roman)
46 romandict[n] = diff * " " + roman
47
48 # justify left
49 for n,name in enumerate(namedict.values()):
50 if len(name) < longestname:
51 diff = longestname - len(name)
52 namedict[n] = name + diff * " "
53
54 for n in romandict.keys():
55 print " %s %s %s" % (romandict[n], namedict[n], linenumdict[n])
56
57
Something went wrong with that request. Please try again.