(fh, base_path: pathlib.Path, path_prefix=None)
| 376 | |
| 377 | |
| 378 | def create_tar_from_directory(fh, base_path: pathlib.Path, path_prefix=None): |
| 379 | with tarfile.open(name="", mode="w", fileobj=fh) as tf: |
| 380 | for root, dirs, files in os.walk(base_path): |
| 381 | dirs.sort() |
| 382 | |
| 383 | for f in sorted(files): |
| 384 | full = base_path / root / f |
| 385 | rel = full.relative_to(base_path) |
| 386 | if path_prefix: |
| 387 | rel = pathlib.Path(path_prefix) / rel |
| 388 | tf.add(full, rel) |
| 389 | |
| 390 | |
| 391 | def extract_tar_to_directory(source: pathlib.Path, dest: pathlib.Path): |
no outgoing calls
no test coverage detected