MCPcopy
hub / github.com/pathwaycom/pathway / write_lines

Function write_lines

python/pathway/tests/utils.py:790–799  ·  view source on GitHub ↗
(path: str | pathlib.Path, data: str | list[str])

Source from the content-addressed store, hash-verified

788
789
790def write_lines(path: str | pathlib.Path, data: str | list[str]):
791 if isinstance(data, str):
792 data = [data]
793 data = [row + "\n" for row in data]
794
795 with tempfile.NamedTemporaryFile(mode="w+", delete=False) as f:
796 f.writelines(data)
797 tmp_path = f.name
798 # Move is atomic in POSIX filesystems, that makes the whole write atomic as a result
799 os.replace(tmp_path, path)
800
801
802def read_lines(path: str | pathlib.Path) -> list[str]:

Callers 15

test_json_in_csvFunction · 0.90
run_computationFunction · 0.90
wait_resultFunction · 0.90
test_schemas_compositionFunction · 0.90
test_json_default_valuesFunction · 0.90
test_fs_plaintextFunction · 0.90
run_computationFunction · 0.90
test_no_pstorageFunction · 0.90

Calls 1

replaceMethod · 0.80

Tested by 15

test_json_in_csvFunction · 0.72
run_computationFunction · 0.72
wait_resultFunction · 0.72
test_schemas_compositionFunction · 0.72
test_json_default_valuesFunction · 0.72
test_fs_plaintextFunction · 0.72
run_computationFunction · 0.72
test_no_pstorageFunction · 0.72