/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/py-502-31-008/main.py
19 строк
643 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
import tarfile import zipfile from pathlib import Path def pack_dir(folder: Path, archive: Path) -> None: with tarfile.open(archive, "w:gz") as tar: tar.add(folder, arcname=folder.name) def split_file(path: Path, chunk_size: int = 50 * 1024 * 1024) -> None: data = path.read_bytes() for i in range(0, len(data), chunk_size): part = path.with_suffix(path.suffix + f".part{i // chunk_size:03d}") part.write_bytes(data[i : i + chunk_size]) def merge_parts(parts: list[Path], out: Path) -> None: with out.open("wb") as fout: for part in sorted(parts): fout.write(part.read_bytes())