content update

templatewriter improved
This commit is contained in:
lars 2006-12-20 01:37:42 +00:00
parent 9c5645e334
commit a5bc96fb7e
16 changed files with 110 additions and 90 deletions

View file

@ -8,15 +8,25 @@ class TemplateWriter:
contentdir = "./content"
tmplfileext = ".tmpl"
outfileext = ".html"
ignore_items = [ ".svn" ]
def __init__(self):
pass
def get_sorted(self, list):
result = list[:]
result.sort()
return result
def string_replace(self, infile, outfile):
template = open(infile).read()
open(outfile,"w").write(template)
text = {}
for tmpl in os.listdir(self.tmpldir):
for tmpl in self.get_sorted(os.listdir(self.tmpldir)):
if tmpl in self.ignore_items:
continue
tmplfile = str(self.tmpldir+"/"+tmpl)
if not os.path.isfile(tmplfile):
print " str.repl: cancelling "+tmplfile+" - not a file"
@ -30,7 +40,9 @@ class TemplateWriter:
def build_sites(self):
'''use all files ending with .tmpl'''
for tmplfile in os.listdir("./"):
for tmplfile in self.get_sorted(os.listdir("./")):
if tmplfile in self.ignore_items:
continue
if tmplfile.rfind(self.tmplfileext) >= 1:
infile = tmplfile
(tmplfilename, tmplfileext)=os.path.splitext(tmplfile)
@ -41,10 +53,14 @@ class TemplateWriter:
def build_sites_from_gerippe(self):
print "Let's build some html files from: "+self.templatefile
for html in os.listdir(self.contentdir):
for html in self.get_sorted(os.listdir(self.contentdir)):
if html in self.ignore_items:
continue
print " building: "+html+self.outfileext
entries = ""
for entry in os.listdir(self.contentdir+"/"+html):
for entry in self.get_sorted(os.listdir(self.contentdir+"/"+html)):
if entry in self.ignore_items:
continue
print " adding entry: "+entry
entries += open(self.contentdir+"/"+html+"/"+entry).read()