Fixes issue when output file does not already exists

This commit is contained in:
Fabien LOISON 2018-11-20 11:13:58 +01:00
parent 2fced9a27f
commit 28a28dac8d
No known key found for this signature in database
GPG Key ID: FF90CA148348048E
1 changed files with 9 additions and 3 deletions

View File

@ -7,9 +7,15 @@ from .model.cli import add_model_cli_options
def _type_path(mode, string):
if os.access(string, mode):
return string
raise argparse.ArgumentTypeError("can't access '%s'" % string)
if os.path.isfile(string):
if os.access(string, mode):
return string
raise argparse.ArgumentTypeError("can't access '%s'" % string)
else:
path = os.path.dirname(os.path.abspath(string))
if os.access(path, mode):
return string
raise argparse.ArgumentTypeError("the '%s' folder does not exist" % path) # noqa
def add_main_cli_arguments(parser):