From de139943d8272773b5f19ed824d687b0232b9ba3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 11 Mar 2023 09:03:03 +0100 Subject: Adding upstream version 0.19.1. Signed-off-by: Daniel Baumann --- qa/utils.py | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) (limited to 'qa/utils.py') diff --git a/qa/utils.py b/qa/utils.py index 89292cd..d560d86 100644 --- a/qa/utils.py +++ b/qa/utils.py @@ -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 - - -DEFAULT_ENCODING = getpreferredencoding() + """Use local.getpreferredencoding() or fallback to UTF-8.""" + return locale.getpreferredencoding() or "UTF-8" + + +TERMINAL_ENCODING = getpreferredencoding() + + +######################################################################################################################## +# FILE_ENCODING + +# Encoding for reading/writing files within the tests, this is always UTF-8 +FILE_ENCODING = "UTF-8" -- cgit v1.2.3