-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake_book.py
executable file
·54 lines (37 loc) · 1.55 KB
/
make_book.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
import os
import tempfile
from pyabo.book_public import TC, SC
from pyabo import nikayas, note_thing, run_abo
from dopdf import sneb2pdf
from doepub import sn2epub, mn2epub, dn2epub, an2epub
try:
import user_config as uc
except ImportError:
import _user_config as uc
def main():
run_abo.make_sure_is_runing()
domain = run_abo.get_domain()
note_thing.load_global(domain, uc.CACHE_DIR)
for xn in "sn", "mn", "dn", "an":
nikayas.load(xn, domain, uc.CACHE_DIR)
temprootdir_td = tempfile.TemporaryDirectory(prefix="pyabo_")
def print_temprootdir():
print("temprootdir: {}".format(temprootdir_td.name))
# books_dir = os.path.join(uc.PROJECT_ROOT, "books", time.strftime("%Y-%m-%d_%H.%M.%S", time.localtime()))
books_dir = uc.BOOKS_DIR
os.makedirs(books_dir, exist_ok=True)
if True:
print_temprootdir()
for xc in (TC(), SC()):
sn2epub.make(xc, temprootdir_td.name, books_dir, uc.EPUBCHECK)
mn2epub.make(xc, temprootdir_td.name, books_dir, uc.EPUBCHECK)
dn2epub.make(xc, temprootdir_td.name, books_dir, uc.EPUBCHECK)
an2epub.make(xc, temprootdir_td.name, books_dir, uc.EPUBCHECK)
sneb2pdf.make(TC(), temprootdir_td.name, books_dir, uc.CONTEXT_BIN_PATH, uc.FONTS_DIR)
sneb2pdf.make(SC(), temprootdir_td.name, books_dir, uc.CONTEXT_BIN_PATH, uc.FONTS_DIR)
# Input e and press enter to exit
while input("输入 e 后按下回车退出:").rstrip() != "e":
pass
if __name__ == "__main__":
main()