summaryrefslogtreecommitdiff
path: root/panfry/main.py
diff options
context:
space:
mode:
authorScott Bahling <sbahling@suse.de>2013-03-23 14:49:42 +0100
committerScott Bahling <sbahling@suse.de>2013-03-23 14:49:42 +0100
commit74edbf065728498c38f1975c97b7d16f40d1903c (patch)
treedbbd610f899b16447a09e7dc36e975c042404b05 /panfry/main.py
parenta62783371454942e4edc1aa6e23b7deb76a268a4 (diff)
downloadpanfry-74edbf065728498c38f1975c97b7d16f40d1903c.tar.gz
panfry-74edbf065728498c38f1975c97b7d16f40d1903c.tar.xz
panfry-74edbf065728498c38f1975c97b7d16f40d1903c.zip
New document file structure
- Document source is to be found under srcdir/src - Templates under srcdir/templates - Assets under srcdir/assets Assets are any files/directories that should be copied to the pubdir but are otherwise unprocessed by panfry. - By default pubdir = srcdir/pub
Diffstat (limited to 'panfry/main.py')
-rwxr-xr-xpanfry/main.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/panfry/main.py b/panfry/main.py
index e09b653..0b88c0a 100755
--- a/panfry/main.py
+++ b/panfry/main.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
import os
import shutil
import panfry.cli
@@ -27,22 +28,31 @@ def get_env():
def main():
env = get_env()
- if os.path.exists(env.pub_path):
- shutil.rmtree(env.pub_path)
- os.mkdir(env.pub_path)
-
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 PDF: %s" % epubfile)
+ print("Wrote epub: %s" % epubfile)
###### Create HTML
document.publish_html(env.pub_path)