# HG changeset patch # User Franz Glasner # Date 1736426937 -3600 # Node ID a813094ae4f57c81f08e439c256721198dd85418 # Parent fa7dd54e9715f7f6b64e02bc466225b44ca6fd5f Move PY2 from cutils.util.constants into cutils.util diff -r fa7dd54e9715 -r a813094ae4f5 cutils/shasum.py --- a/cutils/shasum.py Thu Jan 09 13:40:33 2025 +0100 +++ b/cutils/shasum.py Thu Jan 09 13:48:57 2025 +0100 @@ -24,7 +24,6 @@ from . import (__version__, __revision__) from . import util -from .util import constants from .util import digest @@ -174,7 +173,7 @@ opts.base64) else: if not opts.files or (len(opts.files) == 1 and opts.files[0] == '-'): - if constants.PY2: + if util.PY2: if sys.platform == "win32": import msvcrt # noqa: E401 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) @@ -243,7 +242,7 @@ dest = opts.dest or sys.stdout exit_code = 0 if not opts.files or (len(opts.files) == 1 and opts.files[0] == '-'): - if constants.PY2: + if util.PY2: if sys.platform == "win32": import os, msvcrt # noqa: E401 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) diff -r fa7dd54e9715 -r a813094ae4f5 cutils/util/__init__.py --- a/cutils/util/__init__.py Thu Jan 09 13:40:33 2025 +0100 +++ b/cutils/util/__init__.py Thu Jan 09 13:48:57 2025 +0100 @@ -7,7 +7,8 @@ """ -__all__ = ["normalize_filename", +__all__ = ["PY2", + "normalize_filename", "argv2algo", "algotag2algotype", "get_blake2b", @@ -20,6 +21,10 @@ import argparse import hashlib import os +import sys + + +PY2 = sys.version_info[0] < 3 def get_blake2b(): diff -r fa7dd54e9715 -r a813094ae4f5 cutils/util/constants.py --- a/cutils/util/constants.py Thu Jan 09 13:40:33 2025 +0100 +++ b/cutils/util/constants.py Thu Jan 09 13:48:57 2025 +0100 @@ -7,22 +7,20 @@ """ -__all__ = ["PY2", - "PATH_TYPES", +__all__ = ["PATH_TYPES", "READ_CHUNK_SIZE", "MAX_AUTO_MAP_SIZE", "MAP_WINDOW_SIZE" ] -import sys try: import pathlib except ImportError: pathlib = None +from . import PY2 -PY2 = sys.version_info[0] < 3 if PY2: PATH_TYPES = (unicode, str) # noqa: F821 (undefined name 'unicode') diff -r fa7dd54e9715 -r a813094ae4f5 cutils/util/digest.py --- a/cutils/util/digest.py Thu Jan 09 13:40:33 2025 +0100 +++ b/cutils/util/digest.py Thu Jan 09 13:48:57 2025 +0100 @@ -19,6 +19,7 @@ mmap = None import stat +from . import PY2 from . import constants @@ -79,7 +80,7 @@ fadvise = getattr(os, "posix_fadvise", None) if fadvise: fadvise(fd, 0, 0, os.POSIX_FADV_SEQUENTIAL) - if not constants.PY2: + if not PY2: fileobj = io.FileIO(fd, mode="r", closefd=False) buf = bytearray(constants.READ_CHUNK_SIZE) with memoryview(buf) as full_view: diff -r fa7dd54e9715 -r a813094ae4f5 cutils/util/walk.py --- a/cutils/util/walk.py Thu Jan 09 13:40:33 2025 +0100 +++ b/cutils/util/walk.py Thu Jan 09 13:48:57 2025 +0100 @@ -19,8 +19,8 @@ except ImportError: scandir = None +from . import PY2 from .cm import nullcontext -from .constants import PY2 class WalkDirEntry(object):