-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrender.py
More file actions
26 lines (23 loc) · 742 Bytes
/
Copy pathrender.py
File metadata and controls
26 lines (23 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from jinja2 import Template
import os
import json
from interfaces import Book, Preference
from db import load_books, load_prefs
cache = None
configs = None
def clean_book_name(path):
return os.path.split(path)[-1]
def load_if_exists(filename):
configs = []
if os.path.exists(filename):
with open(filename, 'r') as f:
configs = json.load(f)
return configs
if __name__ == "__main__":
books = load_books()
prefs = load_prefs()
with open("./index-jinja2.html", 'r', encoding='utf-8') as f:
template = Template(f.read())
with open("./index.html", 'w', encoding='utf-8') as f:
f.write(template.render(
{"books": books, "clean": clean_book_name, "configs": prefs}))