blob: 88b4a417f65949c7363c7ce141513eaae0467578 (
plain)
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
43
44
|
#!/usr/bin/python
#
#utility to remove 'activity' from .html files and replace with horizontal rule tag
from path import path
import os, sys, subprocess
from optparse import OptionParser
SOURCE = path('../')
parser = OptionParser(usage="Usage: %prog [options] file")
(options, args) = parser.parse_args()
if not args:
print 'Specify a course and milestone, e.g. zs5 zs5m08'
parser.print_help()
sys.exit(1)
SUBJECT = args[0]
COURSE = args[1]
MILESTONE = args[2]
tag = '<hr />'
basepath = SOURCE / SUBJECT / COURSE / MILESTONE
files = basepath.files('*.html')
file = files[0]
fin = open(basepath / file.name,'r')
txt = fin.read()
fin.close()
pos = txt.find('Activity')
count = 0
while pos > -1:
pos1 = txt.find('<CENTER>')
pos2 = txt.find('</CENTER>')
if pos1 < 0 or pos2 < 0:
pos = -1
continue
if count < 1:
txt = txt[:pos1]+txt[pos2+9:]
else:
txt = txt[:pos1] + '<hr />' + txt[pos2+9:]
count += 1
pos = txt.find('Activity')
print count, pos, len(txt)
fout = open(basepath / MILESTONE+'.html','w')
fout.write(txt)
fout.close
|