Create output dir if needed

This commit is contained in:
Jake Howard 2017-05-03 21:10:18 +01:00
parent 44bf3c962f
commit 9108301772
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import logging
from md_pdf.args import parse_args
from md_pdf.exceptions import PrematureExit, BaseException
from md_pdf.exceptions import BaseException
from md_pdf.logging import set_verbosity
from md_pdf.build import build
from md_pdf.config.read import load_config

View file

@ -24,7 +24,8 @@ def check_required_keys(config):
def test_output(config):
abs_output_dir = os.path.abspath(config['output_dir'])
if not os.path.isdir(abs_output_dir):
raise ConfigValidationException("Can't find output directory '{}'".format(abs_output_dir))
logger.debug("Creating output directory...")
os.mkdir(abs_output_dir)
invalid_formats = [key for key in config['output_formats'] if key not in ['html', 'pdf']]
if invalid_formats:
raise ConfigValidationException("Invalid output formats provided: '{}'".format(", ".join(invalid_formats)))