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(writer): Always specify the encoding as UTF-8 #36

Merged
merged 1 commit into from
Jul 3, 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
10 changes: 6 additions & 4 deletions honeybee_idaice/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,15 @@ def model_to_idm(
templates_folder = __here__.joinpath('templates')

# create building file that includes building bodies and a reference to the rooms
with bldg_file.open('w', encoding='UTF-8') as bldg:
with bldg_file.open('w', encoding='utf-8') as bldg:
header = ';IDA 4.80002 Data UTF-8\n' \
'(DOCUMENT-HEADER :TYPE BUILDING :N "{}" :MS 4 :CK ' \
'((RECENT (WINDEF . "Double Clear Air (WIN7)"))) ' \
':PARENT ICE :APP (ICE :VER 4.802))\n'.format(bldg_name)
bldg.write(header)
# add template values
bldg_template = templates_folder.joinpath('building.idm')
for line in bldg_template.open('r'):
for line in bldg_template.open('r', encoding='utf-8'):
bldg.write(line)

# create a building sections/bodies for the building
Expand All @@ -495,7 +495,8 @@ def model_to_idm(
for template in templates:
template_file = templates_folder.joinpath(template)
target_file = bldg_folder.joinpath(template)
with target_file.open('w') as outf, template_file.open('r') as inf:
with target_file.open('w', encoding='utf-8') as outf, \
template_file.open('r', encoding='utf-8') as inf:
for line in inf:
outf.write(f'{line.rstrip()}\n')
outf.write(f';[end of {bldg_name}\\{template_file}]\n')
Expand All @@ -505,7 +506,8 @@ def model_to_idm(
for room in model.rooms:
room_name = room.display_name
room_file = bldg_folder.joinpath(f'{room_name}.idm')
with template_room.open('r') as inf, room_file.open('w') as rm:
with template_room.open('r', encoding='utf-8') as inf, \
room_file.open('w', encoding='utf-8') as rm:
for line in inf:
rm.write(f'{line.rstrip()}\n')
geometry = room_to_idm(
Expand Down
Loading