12345678910111213141516171819202122232425 |
- import chevron
- from glob import glob
- import os
- import json
-
- MAX_FILES = 20
-
- titles=json.load(open("logs/titles.json"))
-
- def title(filename):
- return titles.get(filename, filename.split('.')[0])
-
- def genlog():
- os.chdir('logs')
- filenames = list(reversed(sorted(glob("*.txt"))))[:MAX_FILES]
- files = [
- {"filename": f, "title": titles.get(f, f.split(".")[0])}
- for f in filenames
- ]
- with open('../logs.tmpl') as fin:
- with open('index.html','w') as fout:
- fout.write(chevron.render(fin, {"files": files}))
-
- if __name__ == '__main__':
- genlog()
|