From f77981327eb61b89714f3cc7be0203029a9a7b9a Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 11 Oct 2018 18:38:21 +0100 Subject: [PATCH] cli: must create output directory if it doesn't exist already --- Lib/cu2qu/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/cu2qu/cli.py b/Lib/cu2qu/cli.py index 03c4ee4..5c1f44b 100644 --- a/Lib/cu2qu/cli.py +++ b/Lib/cu2qu/cli.py @@ -118,8 +118,13 @@ def main(args=None): parser.error("-o/--output-file can't be used with multile inputs") if options.output_dir: + output_dir = options.output_dir + if not os.path.exists(output_dir): + os.mkdir(output_dir) + elif not os.path.isdir(output_dir): + parser.error("'%s' is not a directory" % output_dir) output_paths = [ - os.path.join(options.output_dir, os.path.basename(p)) + os.path.join(output_dir, os.path.basename(p)) for p in options.infiles ] elif options.output_file: