From 9108301772261baa9b4fadb9af212817ce10bea2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 21:10:18 +0100 Subject: [PATCH] Create output dir if needed --- md_pdf/cli.py | 2 +- md_pdf/config/validate.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/md_pdf/cli.py b/md_pdf/cli.py index ccc136c..4b7dec6 100644 --- a/md_pdf/cli.py +++ b/md_pdf/cli.py @@ -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 diff --git a/md_pdf/config/validate.py b/md_pdf/config/validate.py index 3a66882..a9d5623 100644 --- a/md_pdf/config/validate.py +++ b/md_pdf/config/validate.py @@ -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)))