(UNIX only) Return path to a compressed version of the input filename
(f_name: NPath, level: int = 6)
| 49 | |
| 50 | @contextmanager |
| 51 | def unix_compress_file(f_name: NPath, level: int = 6) -> t.Generator[str, None, None]: |
| 52 | """(UNIX only) Return path to a compressed version of the input filename""" |
| 53 | subprocess.run(["gzip", "-kf", f"-{level}", f_name], check=True) |
| 54 | f_name_gz = f"{f_name}.gz" |
| 55 | try: |
| 56 | yield f_name_gz |
| 57 | finally: |
| 58 | os.unlink(f_name_gz) |
| 59 | |
| 60 | |
| 61 | @contextmanager |