%d more posts in the archive.
\n' ) indexf.write('585 more posts in the older archives.
\n') # Technorati tags go here for t1 in ttag.keys(): indexf.write(t1) # Write the lists out to the rss file for topline in rsstop: rss.write(topline) for botline in rssbot: rss.write(botline) for endline in rssend: rss.write(endline) rss.close() return rewritecount # Main program # we rewrite the index file and the archive file modelled on what # we find in MODEL # If all the files live in one directory, uncomment the following indexf = open(ROOTDIR + os.sep + "index.new", "w") archive = open(ROOTDIR + os.sep + "archive.new", "w") rss = open(ROOTDIR + os.sep + "rss.new", "w") modtime = time.ctime(time.time()) ttag = {} model = open(ROOTDIR + os.sep + SUBDIR + os.sep + MODEL) while 1: inl = model.readline() if not inl: break # where we see the INSERTCONTENT line in MODEL, we insert our own content. #if re.match(r'\s*585 more posts in the older archives.
\n') # where we see the line, we insert the publication date. #if re.match(r'', inl): if re.search(r'', inl): inl = "Last Modified: %s\n" % modtime indexf.write(inl) archive.write(inl) # All the generated files should be done when we fall out of the loop indexf.close() archive.close() # we do nothing permanent until everything has succeeded. print "rewritecount",rewritecount if (rewritecount > MINREWRITES): print "commit changes" os.rename(ROOTDIR + os.sep + 'index.new',ROOTDIR + os.sep + INDEX) os.rename(ROOTDIR + os.sep + 'archive.new',ROOTDIR + os.sep + ARCHIVE) os.rename(ROOTDIR + os.sep + 'rss.new',ROOTDIR + os.sep + RSSOUT) shutil.copyfile(ROOTDIR + os.sep + 'index.html',ROOTDIR + os.sep + 'index.htm') shutil.copyfile(ROOTDIR + os.sep + INDEX,ROOTDIR + os.sep + ALTINDEX) else: os.unlink(ROOTDIR + os.sep + 'index.new') os.unlink(ROOTDIR + os.sep + 'archive.new') os.unlink(ROOTDIR + os.sep + 'rss.new')