1
0
Fork 0

Merging upstream version 0.19.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 06:07:32 +01:00
parent 61e6dccee9
commit 2efee3d3ab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
111 changed files with 2058 additions and 1676 deletions

View file

@ -1,8 +1,6 @@
# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return
import platform
import os
import locale
import os
import platform
########################################################################################################################
# PLATFORM_IS_WINDOWS
@ -31,32 +29,20 @@ def use_sh_library():
USE_SH_LIB = use_sh_library()
########################################################################################################################
# DEFAULT_ENCODING
# TERMINAL_ENCODING
# Encoding for reading gitlint command output
def getpreferredencoding():
"""Modified version of local.getpreferredencoding() that takes into account LC_ALL, LC_CTYPE, LANG env vars
on windows and falls back to UTF-8."""
default_encoding = locale.getpreferredencoding() or "UTF-8"
# On Windows, we mimic git/linux by trying to read the LC_ALL, LC_CTYPE, LANG env vars manually
# (on Linux/MacOS the `getpreferredencoding()` call will take care of this).
# We fallback to UTF-8
if PLATFORM_IS_WINDOWS:
default_encoding = "UTF-8"
for env_var in ["LC_ALL", "LC_CTYPE", "LANG"]:
encoding = os.environ.get(env_var, False)
if encoding:
# Support dotted (C.UTF-8) and non-dotted (C or UTF-8) charsets:
# If encoding contains a dot: split and use second part, otherwise use everything
dot_index = encoding.find(".")
if dot_index != -1:
default_encoding = encoding[dot_index + 1 :]
else:
default_encoding = encoding
break
return default_encoding
"""Use local.getpreferredencoding() or fallback to UTF-8."""
return locale.getpreferredencoding() or "UTF-8"
DEFAULT_ENCODING = getpreferredencoding()
TERMINAL_ENCODING = getpreferredencoding()
########################################################################################################################
# FILE_ENCODING
# Encoding for reading/writing files within the tests, this is always UTF-8
FILE_ENCODING = "UTF-8"