import chevron from glob import glob import os MAX_FILES = 20 def genlog(): os.chdir('logs') filenames = list(reversed(sorted(glob("*.txt"))))[:MAX_FILES] with open('../logs.tmpl') as fin: with open('index.html','w') as fout: fout.write(chevron.render(fin, {"filenames": filenames})) if __name__ == '__main__': genlog()