Skip to content

Commit 032a4a5

Browse files
committed
Add script that generates page numbers.
1 parent c194220 commit 032a4a5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

build_index.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
3+
import glob
4+
import os
5+
import sys
6+
7+
sys.path.insert(0, 'publisher')
8+
9+
import options
10+
11+
output_dir = 'output'
12+
dirs = [d for d in glob.glob('%s/*' % output_dir) if os.path.isdir(d)]
13+
14+
pages = []
15+
cum_pages = [1]
16+
17+
for d in sorted(dirs):
18+
try:
19+
stats = options.cfg2dict(os.path.join(d, 'paper_stats.cfg'))
20+
pages.append(int(stats['pages']))
21+
cum_pages.append(cum_pages[-1] + pages[-1])
22+
23+
print '"%s" from p. %s to %s' % (os.path.basename(d), cum_pages[-2],
24+
cum_pages[-1] - 1)
25+
26+
f = open(os.path.join(d, 'page_numbers.tex'), 'w')
27+
f.write('\setcounter{page}{%s}' % cum_pages[-2])
28+
f.close()
29+
except IOError, e:
30+
continue

0 commit comments

Comments
 (0)