From b9a2719691b4c6cf83f31eb0b6c3e7e878524c0e Mon Sep 17 00:00:00 2001 From: Tony Anderson Date: Mon, 25 Apr 2011 10:33:11 +0000 Subject: initial commit --- (limited to 'makeActivities.py') 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 = '
' +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('
') + pos2 = txt.find('
') + if pos1 < 0 or pos2 < 0: + pos = -1 + continue + if count < 1: + txt = txt[:pos1]+txt[pos2+9:] + else: + txt = txt[:pos1] + '
' + 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 -- cgit v0.9.1