From eef15ff67a207e63fc64508a35dee3c9734ab60a Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Fri, 8 Sep 2023 23:32:08 +0200 Subject: [PATCH] Insignificant improvements to git_helper and compress_files --- tests/ci/compress_files.py | 7 ++++--- tests/ci/git_helper.py | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ci/compress_files.py b/tests/ci/compress_files.py index d8e691ce3b4..6d0a33fdbae 100644 --- a/tests/ci/compress_files.py +++ b/tests/ci/compress_files.py @@ -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, diff --git a/tests/ci/git_helper.py b/tests/ci/git_helper.py index 3f5e3627b4a..9927d5a4248 100644 --- a/tests/ci/git_helper.py +++ b/tests/ci/git_helper.py @@ -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" )