Skip to content

Commit 79e4023

Browse files
committed
expand.py: tidy output processing
1 parent 4289613 commit 79e4023

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

expand.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ def output_file(filename):
119119
print(i, file=f)
120120
output_data = subprocess.run(["rustfmt", temp_file], check=True)
121121
with open(temp_file, 'r', encoding='utf-8', newline='') as f:
122-
if output_path is None:
123-
for line in f:
124-
print(line, end="", file=sys.stdout)
125-
else:
126-
with open(output_path, 'w', encoding='utf-8', newline='') as wf:
127-
for line in f:
128-
print(line, end="", file=wf)
122+
wf = open(output_path, 'w', encoding='utf-8', newline='') if output_path is not None else sys.stdout
123+
for line in f:
124+
print(line, end='', file=wf)
125+
if output_path is not None:
126+
wf.close()

0 commit comments

Comments
 (0)