error handling while creating output dir

This commit is contained in:
Robert Kaussow 2019-10-09 23:23:14 +02:00
parent 8664a48477
commit c8a860825c

View File

@ -52,10 +52,12 @@ class Generator:
self.logger.debug("Ignoring template file: " + relative_file)
def _create_dir(self, directory):
if not self.config.config["dry_run"]:
os.makedirs(directory, exist_ok=True)
else:
self.logger.info("Creating dir: " + directory)
if not self.config.config["dry_run"] and not os.path.isdir(directory):
try:
os.makedirs(directory, exist_ok=True)
self.logger.info("Creating dir: " + directory)
except FileExistsError as e:
self.log.sysexit_with_message(str(e))
def _write_doc(self):
files_to_overwite = []