Add more logging

This commit is contained in:
Jake Howard 2017-04-04 22:04:25 +01:00
parent c1a3947359
commit b839fe28ee
3 changed files with 6 additions and 3 deletions

View file

@ -9,7 +9,7 @@ logger = logging.getLogger(__file__)
def build(config): def build(config):
logger.info("Starting Build...") logger.debug("Starting Build...")
data = read_files(os.path.abspath(config['input'])) data = read_files(os.path.abspath(config['input']))
doc = build_document(data, config.get('bibliography'), config.get('context')) doc = build_document(data, config.get('bibliography'), config.get('context'))
if 'html' in config['output_formats']: if 'html' in config['output_formats']:

View file

@ -11,7 +11,7 @@ OUTPUT_COVER_FILE = os.path.join(ASSET_DIR, 'cover.html')
def render_cover(config): def render_cover(config):
logger.info("Rendering Cover...") logger.debug("Rendering Cover...")
context = config['context'].copy() context = config['context'].copy()
context['title'] = config['title'] context['title'] = config['title']
with open(COVER_TEMPLATE) as f: with open(COVER_TEMPLATE) as f:

View file

@ -9,6 +9,7 @@ logger = logging.getLogger(__file__)
def fix_references_title(content): def fix_references_title(content):
logger.debug("Adding Reference Title...")
soup = BeautifulSoup(content, 'html.parser') soup = BeautifulSoup(content, 'html.parser')
reference_element = soup.find('div', class_='references') reference_element = soup.find('div', class_='references')
if reference_element is not None: if reference_element is not None:
@ -19,11 +20,13 @@ def fix_references_title(content):
def output_html(html, out_dir): def output_html(html, out_dir):
logger.info("Outputting HTML...")
with open(os.path.join(out_dir, 'output.html'), 'w') as f: with open(os.path.join(out_dir, 'output.html'), 'w') as f:
f.write(html) f.write(html)
def parse_template(html, context): def parse_template(html, context):
logger.debug("Rendering Template...")
template = Template(html) template = Template(html)
return template.render(context) return template.render(context)
@ -39,7 +42,7 @@ def build_document(files_content, bibliography, context):
'--csl={}'.format(os.path.join(CSL_DIR, "{}.csl".format(bibliography['csl']))) '--csl={}'.format(os.path.join(CSL_DIR, "{}.csl".format(bibliography['csl'])))
] ]
filters.append('pandoc-citeproc') filters.append('pandoc-citeproc')
logger.info("Rendering HTML...") logger.info("Rendering Document...")
html = fix_references_title(pypandoc.convert_text( html = fix_references_title(pypandoc.convert_text(
files_content, files_content,
'html', 'html',