Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validate): Ensure creation of directories uses abspath #636

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions honeybee/cli/validate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""honeybee validation commands."""
import sys
import os
import logging
import click

from ladybug.commandutil import process_content_to_output
from honeybee.model import Model

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -111,7 +111,7 @@ def validate_model(model_file, extension='All', json=False, output_file=None,
If None, the string will simply be returned from this method.
"""
report = Model.validate(model_file, 'check_for_extension', [extension], json)
return _process_report_output(report, output_file)
return process_content_to_output(report, output_file)


@validate.command('rooms-solid')
Expand Down Expand Up @@ -167,7 +167,7 @@ def validate_rooms_solid(model_file, json=False, output_file=None, plain_text=Tr
If None, the string will simply be returned from this method.
"""
report = Model.validate(model_file, 'check_rooms_solid', json_output=json)
return _process_report_output(report, output_file)
return process_content_to_output(report, output_file)


@validate.command('room-collisions')
Expand Down Expand Up @@ -222,20 +222,4 @@ def validate_room_collisions(model_file, json=False, output_file=None, plain_tex
If None, the string will simply be returned from this method.
"""
report = Model.validate(model_file, 'check_room_volume_collisions', json_output=json)
return _process_report_output(report, output_file)


def _process_report_output(report, output_file):
"""Process a validation report for various types of output_files."""
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))
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))
output_file.write(report)
return process_content_to_output(report, output_file)
Loading