From 72617d979ee8f8589ee001bff57cd31d5a403cee Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Wed, 11 Dec 2024 12:33:09 -0800 Subject: [PATCH] fix(validate): Ensure creation of directories uses abspath --- honeybee/cli/validate.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/honeybee/cli/validate.py b/honeybee/cli/validate.py index 4f62be88..f58bd068 100644 --- a/honeybee/cli/validate.py +++ b/honeybee/cli/validate.py @@ -230,12 +230,14 @@ def _process_report_output(report, output_file): if output_file is None: return report elif isinstance(output_file, str): - if not os.path.isdir(os.path.dirname(output_file)): - os.makedirs(os.path.dirname(output_file)) + dir_name = os.path.dirname(os.path.abspath(output_file)) + if not os.path.isdir(dir_name): + os.makedirs(dir_name) with open(output_file, 'w') as of: of.write(report) else: if 'stdout' not in str(output_file): - if not os.path.isdir(os.path.dirname(output_file.name)): - os.makedirs(os.path.dirname(output_file.name)) + dir_name = os.path.dirname(os.path.abspath(output_file.name)) + if not os.path.isdir(dir_name): + os.makedirs(dir_name) output_file.write(report)