Skip to content

Commit

Permalink
Auto-create missing output folder if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Oct 7, 2024
1 parent 24a12df commit 95f77ea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions markmeld/melder.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,12 @@ def run_command_for_target(self, tgt, print_only, vardump=False):
_LOGGER.error("No input detected. Check variable names")
tgt.returncode = 2
else:
# Create output folder if it doesn't exist:
if tgt.meta["output_file"] and not os.path.exists(
os.path.dirname(tgt.meta["output_file"])
):
_LOGGER.warning(f"Missing output folder. Creating output folder: {os.path.dirname(tgt.meta['output_file'])}")
os.makedirs(os.path.dirname(tgt.meta["output_file"]))
tgt.returncode = run_cmd(
cmd_fmt, tgt.melded_output.encode(), tgt.meta["_workpath"]
)
Expand Down

0 comments on commit 95f77ea

Please sign in to comment.