Insignificant improvements to git_helper and compress_files

This commit is contained in:
Mikhail f. Shiryaev 2023-09-08 23:32:08 +02:00
parent 2f8f16a864
commit eef15ff67a
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4
2 changed files with 6 additions and 6 deletions

View File

@ -7,10 +7,11 @@ from typing import Optional
PIGZ = Path("/usr/bin/pigz")
SUFFIX = ".zst"
def compress_file_fast(path: Path, archive_path: Path) -> None:
if archive_path.suffix == ".zst":
if archive_path.suffix == SUFFIX:
subprocess.check_call(f"zstd < {path} > {archive_path}", shell=True)
elif PIGZ.exists():
subprocess.check_call(f"pigz < {path} > {archive_path}", shell=True)
@ -22,7 +23,7 @@ def compress_fast(
path: Path, archive_path: Path, exclude: Optional[Path] = None
) -> None:
program_part = ""
if archive_path.suffix == ".zst":
if archive_path.suffix == SUFFIX:
logging.info("zstd will be used for compression")
program_part = "--use-compress-program='zstd --threads=0'"
elif PIGZ.exists():
@ -50,7 +51,7 @@ def compress_fast(
def decompress_fast(archive_path: Path, result_path: Optional[Path] = None) -> None:
program_part = ""
if archive_path.suffix == ".zst":
if archive_path.suffix == SUFFIX:
logging.info(
"zstd will be used for decompression ('%s' -> '%s')",
archive_path,

View File

@ -14,7 +14,7 @@ RELEASE_BRANCH_REGEXP = r"\A\d+[.]\d+\Z"
TAG_REGEXP = (
r"\Av\d{2}[.][1-9]\d*[.][1-9]\d*[.][1-9]\d*-(testing|prestable|stable|lts)\Z"
)
SHA_REGEXP = r"\A([0-9]|[a-f]){40}\Z"
SHA_REGEXP = re.compile(r"\A([0-9]|[a-f]){40}\Z")
CWD = p.dirname(p.realpath(__file__))
TWEAK = 1
@ -34,8 +34,7 @@ def removesuffix(string: str, suffix: str) -> str:
def commit(name: str) -> str:
r = re.compile(SHA_REGEXP)
if not r.match(name):
if not SHA_REGEXP.match(name):
raise argparse.ArgumentTypeError(
"commit hash should contain exactly 40 hex characters"
)