Debian Codegraph @

qa/utils.py

raw symbols SCIP
1 import locale
2 import os
3 import platform
4
5 ########################################################################################################################
6 # PLATFORM_IS_WINDOWS
7
8
9 def platform_is_windows():
10 return "windows" in platform.system().lower()
11
12
13 PLATFORM_IS_WINDOWS = platform_is_windows()
14
15 ########################################################################################################################
16 # USE_SH_LIB
17 # Determine whether to use the `sh` library
18 # On windows we won't want to use the sh library since it's not supported - instead we'll use our own shell module.
19 # However, we want to be able to overwrite this behavior for testing using the GITLINT_QA_USE_SH_LIB env var.
20
21
22 def use_sh_library():
23 gitlint_use_sh_lib_env = os.environ.get("GITLINT_QA_USE_SH_LIB", None)
24 if gitlint_use_sh_lib_env:
25 return gitlint_use_sh_lib_env == "1"
26 return not PLATFORM_IS_WINDOWS
27
28
29 USE_SH_LIB = use_sh_library()
30
31 ########################################################################################################################
32 # TERMINAL_ENCODING
33 # Encoding for reading gitlint command output
34
35
36 def getpreferredencoding():
37 """Use local.getpreferredencoding() or fallback to UTF-8."""
38 return locale.getpreferredencoding() or "UTF-8"
39
40
41 TERMINAL_ENCODING = getpreferredencoding()
42
43
44 ########################################################################################################################
45 # FILE_ENCODING
46
47 # Encoding for reading/writing files within the tests, this is always UTF-8
48 FILE_ENCODING = "UTF-8"