cleanup versionchecks

This commit is contained in:
ed 2022-09-25 21:31:47 +02:00
parent e00e80ae39
commit 1c66d06702
6 changed files with 8 additions and 32 deletions

View file

@ -48,7 +48,7 @@ except ImportError:
# from copyparty/__init__.py # from copyparty/__init__.py
PY2 = sys.version_info[0] == 2 PY2 = sys.version_info < (3,)
if PY2: if PY2:
from Queue import Queue from Queue import Queue
from urllib import unquote from urllib import unquote

View file

@ -11,7 +11,7 @@ try:
except: except:
TYPE_CHECKING = False TYPE_CHECKING = False
PY2 = sys.version_info[0] == 2 PY2 = sys.version_info < (3,)
if PY2: if PY2:
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
unicode = unicode # noqa: F821 # pylint: disable=undefined-variable,self-assigning-variable unicode = unicode # noqa: F821 # pylint: disable=undefined-variable,self-assigning-variable

View file

@ -16,7 +16,7 @@ import codecs
import platform import platform
import sys import sys
PY3 = sys.version_info[0] > 2 PY3 = sys.version_info > (3,)
WINDOWS = platform.system() == "Windows" WINDOWS = platform.system() == "Windows"
FS_ERRORS = "surrogateescape" FS_ERRORS = "surrogateescape"
@ -26,20 +26,6 @@ except:
pass pass
def u(text: Any) -> str:
if PY3:
return text
else:
return text.decode("unicode_escape")
def b(data: Any) -> bytes:
if PY3:
return data.encode("latin1")
else:
return data
if PY3: if PY3:
_unichr = chr _unichr = chr
bytes_chr = lambda code: bytes((code,)) bytes_chr = lambda code: bytes((code,))
@ -171,9 +157,6 @@ def decodefilename(fn: bytes) -> str:
FS_ENCODING = sys.getfilesystemencoding() FS_ENCODING = sys.getfilesystemencoding()
# FS_ENCODING = "ascii"; fn = b("[abc\xff]"); encoded = u("[abc\udcff]")
# FS_ENCODING = 'cp932'; fn = b('[abc\x81\x00]'); encoded = u('[abc\udc81\x00]')
# FS_ENCODING = 'UTF-8'; fn = b('[abc\xff]'); encoded = u('[abc\udcff]')
if WINDOWS and not PY3: if WINDOWS and not PY3:

View file

@ -480,17 +480,10 @@ class SvcHub(object):
print(*a, **ka) print(*a, **ka)
def check_mp_support(self) -> str: def check_mp_support(self) -> str:
vmin = sys.version_info[1] if MACOS:
if WINDOWS:
msg = "need python 3.3 or newer for multiprocessing;"
if PY2 or vmin < 3:
return msg
elif MACOS:
return "multiprocessing is wonky on mac osx;" return "multiprocessing is wonky on mac osx;"
else: elif sys.version_info < (3, 3):
msg = "need python 3.3+ for multiprocessing;" return "need python 3.3 or newer for multiprocessing;"
if PY2 or vmin < 3:
return msg
try: try:
x: mp.Queue[tuple[str, str]] = mp.Queue(1) x: mp.Queue[tuple[str, str]] = mp.Queue(1)

View file

@ -120,7 +120,7 @@ else:
FS_ENCODING = sys.getfilesystemencoding() FS_ENCODING = sys.getfilesystemencoding()
SYMTIME = sys.version_info >= (3, 6) and os.utime in os.supports_follow_symlinks SYMTIME = sys.version_info > (3, 6) and os.utime in os.supports_follow_symlinks
HTTP_TS_FMT = "%a, %d %b %Y %H:%M:%S GMT" HTTP_TS_FMT = "%a, %d %b %Y %H:%M:%S GMT"

View file

@ -27,7 +27,7 @@ SIZE = None
CKSUM = None CKSUM = None
STAMP = None STAMP = None
PY2 = sys.version_info[0] == 2 PY2 = sys.version_info < (3,)
WINDOWS = sys.platform in ["win32", "msys"] WINDOWS = sys.platform in ["win32", "msys"]
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
me = os.path.abspath(os.path.realpath(__file__)) me = os.path.abspath(os.path.realpath(__file__))