Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/makeActivities.py
diff options
context:
space:
mode:
Diffstat (limited to 'makeActivities.py')
-rwxr-xr-xmakeActivities.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/makeActivities.py b/makeActivities.py
new file mode 100755
index 0000000..88b4a41
--- /dev/null
+++ b/makeActivities.py
@@ -0,0 +1,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