diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-11 08:03:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-11 08:03:03 +0000 |
commit | de139943d8272773b5f19ed824d687b0232b9ba3 (patch) | |
tree | 47e73755bffd41bdde2d59d76cc595f5a1fa75d4 /qa/utils.py | |
parent | Adding upstream version 0.19.0~dev. (diff) | |
download | gitlint-upstream.tar.xz gitlint-upstream.zip |
Adding upstream version 0.19.1.upstream/0.19.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | qa/utils.py | 46 |
1 files changed, 16 insertions, 30 deletions
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" |