Skip to content

Commit

Permalink
fix(px): pcompos input bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
taoning committed Aug 23, 2024
1 parent e8a5179 commit 159b4a5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pyradiance/px.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def pcompos(
bytes: output of pcompos
"""
cmd = [str(BINPATH / "pcompos")]
stdin = None
if ncols is not None:
cmd.extend(["-a", str(ncols)])
if spacing > 0:
Expand Down Expand Up @@ -149,9 +150,17 @@ def pcompos(
if anchors is not None:
if anchors[i] is not None:
cmd.append(f"={anchors[i]}")
cmd.append(str(input))
if isinstance(input, (str, Path)):
cmd.append(str(input))
elif isinstance(input, bytes):
if stdin is not None:
raise ValueError("Only one bytes input is allowed with pcompos.")
stdin = input
cmd.append("-")
else:
raise ValueError(f"Unsupported input type: {type(input)}")
cmd.extend(list(map(str, pos[i])))
return sp.run(cmd, stdout=sp.PIPE).stdout
return sp.run(cmd, input=stdin, stdout=sp.PIPE).stdout


@handle_called_process_error
Expand Down

0 comments on commit 159b4a5

Please sign in to comment.