(entries: Iterable[tuple[str, str]], output: Path | None)
| 57 | |
| 58 | |
| 59 | def write_outputs(entries: Iterable[tuple[str, str]], output: Path | None) -> None: |
| 60 | lines: list[str] = [] |
| 61 | for key, value in entries: |
| 62 | delimiter = "" |
| 63 | if "\n" in value: |
| 64 | delimiter = "__GH_OUTPUT__" |
| 65 | while delimiter in value: |
| 66 | delimiter += "_X" |
| 67 | lines.append(f"{key}<<{delimiter}\n{value}\n{delimiter}") |
| 68 | else: |
| 69 | lines.append(f"{key}={value}") |
| 70 | |
| 71 | content = "\n".join(lines) + "\n" |
| 72 | if output: |
| 73 | output.parent.mkdir(parents=True, exist_ok=True) |
| 74 | with output.open("a", encoding="utf-8") as fh: |
| 75 | fh.write(content) |
| 76 | else: |
| 77 | print(content, end="") |
| 78 | |
| 79 | |
| 80 | def _normalize_status(status: str) -> str: |
no test coverage detected