Dump `output` to a temporary file. Return path to the file.
(*output: str, ensure_final_newline: bool = True)
| 111 | |
| 112 | @mypyc_attr(patchable=True) |
| 113 | def dump_to_file(*output: str, ensure_final_newline: bool = True) -> str: |
| 114 | class="st">""class="st">"Dump `output` to a temporary file. Return path to the file."class="st">"" |
| 115 | with tempfile.NamedTemporaryFile( |
| 116 | mode=class="st">"w", prefix=class="st">"blk_", suffix=class="st">".log", delete=False, encoding=class="st">"utf8" |
| 117 | ) as f: |
| 118 | for lines in output: |
| 119 | f.write(lines) |
| 120 | if ensure_final_newline and lines and lines[-1] != class="st">"\n": |
| 121 | f.write(class="st">"\n") |
| 122 | return f.name |
no test coverage detected