diff options
Diffstat (limited to 'panfry/main.py')
| -rwxr-xr-x | panfry/main.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/panfry/main.py b/panfry/main.py index 1b90181..5d05d20 100755 --- a/panfry/main.py +++ b/panfry/main.py @@ -33,13 +33,20 @@ class StoppableHttpServer(BaseHTTPServer.HTTPServer): self.handle_request() +def get_INDEX(path, index): + INDEX = os.path.join('src', path, 'INDEX') + if os.path.isfile(INDEX): + for line in open(INDEX, 'r').readlines(): + newpath = os.path.join(path, line.strip()) + index = get_INDEX(newpath, index) + index.append(newpath) + return index + def get_env(): env = panfry.cli.init_argparser().parse_args() env.pub_path = os.path.abspath(env.pub_path) - env.index = [''] if env.cmd in ['gen']: - INDEX = os.path.join(env.doc_path, 'src', 'INDEX') if not os.path.isdir(env.doc_path): print("%s directory not found. Aborting..." % env.doc_path) exit(1) @@ -54,8 +61,8 @@ def get_env(): if env.pandoc_options: env.pandoc_options = list(shlex.split(env.pandoc_options)) - if os.path.isfile(INDEX): - env.index += open(INDEX, 'r').readlines() + env.index = [''] + env.index = get_INDEX('', env.index) return env @@ -63,15 +70,16 @@ def get_env(): def gen(env): for item in env.index: item = item.strip() + print("Processing: %s..." % item) docpubpath = os.path.join(env.pub_path, item) document = Document(env.doc_path, item) - document.set_templater(Templater(env.templates_path)) - document.set_pandoc_options(env.pandoc_options) + document.templater = Templater(env.templates_path) + document.pandoc_options = env.pandoc_options if env.simple_toc: - document.set_simple_toc + document.toc_type = 'simple' if env.json_toc: - document.set_json_toc + document.toc_type = 'json' if env.clean and os.path.exists(env.pub_path): print("Cleanup, removing %s..." % env.pub_path) @@ -93,11 +101,13 @@ def gen(env): ###### Create PDF pdffile = document.publish_pdf(docpubpath) - print("Wrote PDF: %s" % pdffile) + if pdffile: + print("Wrote PDF: %s" % pdffile) ###### Create epub epubfile = document.publish_epub(docpubpath) - print("Wrote epub: %s" % epubfile) + if epubfile: + print("Wrote epub: %s" % epubfile) ###### Create HTML document.publish_html(docpubpath) |
