Function
write_tsv
(
path: pathlib.Path,
*,
metadata: Iterable[tuple[str, object]],
rows: Iterable[dict[str, object]],
)
Source from the content-addressed store, hash-verified
| 421 | |
| 422 | |
| 423 | def write_tsv( |
| 424 | path: pathlib.Path, |
| 425 | *, |
| 426 | metadata: Iterable[tuple[str, object]], |
| 427 | rows: Iterable[dict[str, object]], |
| 428 | ) -> None: |
| 429 | with path.open("x", encoding="utf-8", newline="") as handle: |
| 430 | handle.write("# cbm-release-selection-v1\n") |
| 431 | for key, value in metadata: |
| 432 | handle.write(f"# {key}={value}\n") |
| 433 | writer = csv.DictWriter( |
| 434 | handle, |
| 435 | fieldnames=SELECTION_FIELDS, |
| 436 | delimiter="\t", |
| 437 | lineterminator="\n", |
| 438 | extrasaction="raise", |
| 439 | ) |
| 440 | writer.writeheader() |
| 441 | writer.writerows(rows) |
| 442 | handle.flush() |
| 443 | os.fsync(handle.fileno()) |
| 444 | |
| 445 | |
| 446 | def copy_selected( |
Tested by
no test coverage detected