' + "\n")
archive.write(description + "\n")
archive.write("
\n")
if (SUBDIR == '.'):
archive.write('')
if(good2write == REWSUCCESS):
indexf.write(' ' % IMGMOD) # Posting was modified; mark it
# print "Writing modified file",title
if (SUBDIR == '.'):
indexf.write('>%s%s [permalink]\n' % (title, time.ctime(mtime), fn))
else:
indexf.write('%s%s [permalink]\n' % (title, time.ctime(mtime), SUBDIR, fn))
# print "Writing",title,"decrementing LINECOUNT"
while 1:
LINECOUNT = LINECOUNT - 1
line = inf.readline()
if not line: break
# Avoid nesting the tables
if re.search(r'', line):
# print "Wrote content of ",title
break
indexf.write(line)
itemcontent += line
indexf.write('Keywords: ')
for thekey in keyword:
keywordwords = string.split(thekey)
for single in keywordwords:
indexf.write(DELLINK0 + single + DELLINK1 + single + DELLINK2)
dtag[DELLINK0 + single + DELLINK1 + single + DELLINK2] = 1
indexf.write("|")
indexf.write(" \n")
# Add the comment link line
basefilename = string.split(fn,'.')[0]
comm0 = r' ' + "\n"
indexf.write(comm0 + "'" + basefilename + "'" + comm1 + "'" + basefilename + "'" + comm2 + "'" + basefilename + "'" + comm3 + "'" + basefilename + "'" + comm4)
# Feedflare
indexf.write(FLARE0 + os.getcwd().split('/')[-1] + "/" + basefilename + FLARE1)
indexf.write("")
inf.close()
# Write the lists out to the rss file
# Write up to RSSCOUNT items to the rss file
# print "RSSCOUNT=",RSSCOUNT
if (RSSCOUNT > 0) or (good2write>REWFAIL):
# if (RSSCOUNT > 0):
# if (good2write == REWFAIL):
# continue
#rss.write(rssline % (title, SUBDIR, fn)) # 0.9 format
# print "rssline=",rssline
# Don't output items which have empty content
if (itemcontent != ""):
# print "SUBDIR, fn, title, SUBDIR, fn, description, itemcontent",SUBDIR, fn, title, SUBDIR, fn, description, itemcontent
rssbot.append(rssitem % (SUBDIR, fn, title, SUBDIR, fn, description, itemcontent))
# print "",rssitem,SUBDIR,fn
rsstop.append(rssline % (SUBDIR, fn))
RSSCOUNT = RSSCOUNT - 1
indexf.write("")
indexf.write('
%d more posts in the archives. ' + "\n")
indexf.write('368 more posts in the 2005 archives. \n')
indexf.write('585 more posts in the older archives. \n')
# del.icio.us tags go here
indexf.write(TAGROLL)
# indexf.write('Tags: ')
# for t1 in dtag.keys():
# indexf.write(t1)
# itemcontent += t1
indexf.write(" | ")
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())
dtag = {}
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* $', inl):
if re.search(r'', inl):
archive.write('\n')
rewritecount = writecontent()
#archive.write(' \n')
archive.write('Last month ' + "\n")
archive.write('368 more posts in the 2005 archives. \n')
archive.write('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 +'.html')
shutil.copyfile(ROOTDIR + os.sep + ARCHIVE +'.html',ARCHDIR + os.sep + ARCHIVE +time.strftime("%Y%m",time.localtime()) + '.html')
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')
|