#!/usr/bin/python ######## # # %> ./update.py oldlecturenumber newlecturenumber # ######## # program to update (convert) spring 2004 web pages # to fall 2008 web pages. the steps are the following: # # --change font size from h3 to fontsize=7 # --add fontsize=5 after the title # --change "Astro 6" to "Astronomy 183" # --change "Spring 2004" to "Fall 2008" # --convert old lecture number to new lecture number # # # this program takes no arguments -- it just operates on # every *.html file in the directory. file names are # unchanged (at the end). # # det // 2 sept 2008 # ################################### import os,sys,string,glob # get all html files in this directory filelist = glob.glob('*.html') oldlecturenumber = sys.argv[-2] newlecturenumber = sys.argv[-1] # loop over them for i in filelist: command1 = "< %s sed 's/
dum3" command4 = "< dum3 sed 's/Astro 6/Astronomy 183/' > dum4" command5 = "< dum4 sed 's/Spring 2004/Spring 2009/' > dum5" command5a = "< dum5 sed 's/Spring 2009/Fall 2009/' > dum6" command6 = "< dum6 sed 's/Lecture %s/Lecture %s/' > %s" % (oldlecturenumber,newlecturenumber,i) command7 = "/bin/rm dum?" os.system(command1) os.system(command2) os.system(command3) os.system(command4) os.system(command5) os.system(command5a) os.system(command6) os.system(command7)