Skip to content

Commit

Permalink
edge-case evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
lnxpy committed Jun 1, 2024
1 parent 3aa4d93 commit 68aac0f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyaction/io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
from contextlib import nullcontext
from io import TextIOWrapper

from rich.console import Console
Expand Down Expand Up @@ -36,7 +37,9 @@ def write(
)
console.print(table)
else:
with open(stream, "+w") as streamline:
with nullcontext(stream) if isinstance(stream, TextIOWrapper) else open(
stream, "w+"
) as streamline:
for var, val in context.items():
if "\n" in val:
streamline.write(MULTILINE_OUTPUT.format(variable=var, value=val))
Expand Down

0 comments on commit 68aac0f

Please sign in to comment.