Create output dir if needed
This commit is contained in:
parent
44bf3c962f
commit
9108301772
2 changed files with 3 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from md_pdf.args import parse_args
|
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.logging import set_verbosity
|
||||||
from md_pdf.build import build
|
from md_pdf.build import build
|
||||||
from md_pdf.config.read import load_config
|
from md_pdf.config.read import load_config
|
||||||
|
|
|
@ -24,7 +24,8 @@ def check_required_keys(config):
|
||||||
def test_output(config):
|
def test_output(config):
|
||||||
abs_output_dir = os.path.abspath(config['output_dir'])
|
abs_output_dir = os.path.abspath(config['output_dir'])
|
||||||
if not os.path.isdir(abs_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']]
|
invalid_formats = [key for key in config['output_formats'] if key not in ['html', 'pdf']]
|
||||||
if invalid_formats:
|
if invalid_formats:
|
||||||
raise ConfigValidationException("Invalid output formats provided: '{}'".format(", ".join(invalid_formats)))
|
raise ConfigValidationException("Invalid output formats provided: '{}'".format(", ".join(invalid_formats)))
|
||||||
|
|
Reference in a new issue