blob: 0b88c0a976922ea65dd918c34937dff6bec83075 (
plain)
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
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import shutil
import panfry.cli
from panfry.templater import Templater
from panfry.document import Document
def get_env():
env = panfry.cli.init_argparser().parse_args()
if not os.path.isdir(env.src_path):
print("%s directory not found. Aborting..." % env.src_path)
exit(1)
env.pub_path = os.path.abspath(env.pub_path)
if not env.templates_path:
env.templates_path = os.path.join(env.src_path, 'templates')
if not os.path.isdir(env.templates_path):
print("No templates path found. Aborting...")
exit(1)
return env
def main():
env = get_env()
document = Document(env.src_path)
document.set_templater(Templater(env.templates_path))
if env.simple_toc:
document.set_simple_toc
if env.clean and os.path.exists(env.pub_path):
print("Cleanup, removing %s..." % env.pub_path)
shutil.rmtree(env.pub_path)
if not os.path.exists(env.pub_path):
os.mkdir(env.pub_path)
if env.assets:
print("Publishing assets only...", end=' ')
document.publish_assets(env.pub_path)
print("done.")
exit(0)
###### Create PDF
pdffile = document.publish_pdf(env.pub_path)
print("Wrote PDF: %s" % pdffile)
###### Create epub
epubfile = document.publish_epub(env.pub_path)
print("Wrote epub: %s" % epubfile)
###### Create HTML
document.publish_html(env.pub_path)
exit(0)
if __name__ == "__main__":
main()
|