Server IP : 66.29.132.122 / Your IP : 18.227.190.228 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/flake8/formatting/ |
Upload File : |
"""ctypes hackery to enable color processing on windows. See: https://github.com/pre-commit/pre-commit/blob/cb40e96/pre_commit/color.py """ import sys if sys.platform == "win32": # pragma: no cover (windows) def _enable() -> None: from ctypes import POINTER from ctypes import windll from ctypes import WinError from ctypes import WINFUNCTYPE from ctypes.wintypes import BOOL from ctypes.wintypes import DWORD from ctypes.wintypes import HANDLE STD_ERROR_HANDLE = -12 ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4 def bool_errcheck(result, func, args): if not result: raise WinError() return args GetStdHandle = WINFUNCTYPE(HANDLE, DWORD)( ("GetStdHandle", windll.kernel32), ((1, "nStdHandle"),), ) GetConsoleMode = WINFUNCTYPE(BOOL, HANDLE, POINTER(DWORD))( ("GetConsoleMode", windll.kernel32), ((1, "hConsoleHandle"), (2, "lpMode")), ) GetConsoleMode.errcheck = bool_errcheck SetConsoleMode = WINFUNCTYPE(BOOL, HANDLE, DWORD)( ("SetConsoleMode", windll.kernel32), ((1, "hConsoleHandle"), (1, "dwMode")), ) SetConsoleMode.errcheck = bool_errcheck # As of Windows 10, the Windows console supports (some) ANSI escape # sequences, but it needs to be enabled using `SetConsoleMode` first. # # More info on the escape sequences supported: # https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx stderr = GetStdHandle(STD_ERROR_HANDLE) flags = GetConsoleMode(stderr) SetConsoleMode(stderr, flags | ENABLE_VIRTUAL_TERMINAL_PROCESSING) try: _enable() except OSError: terminal_supports_color = False else: terminal_supports_color = True else: # pragma: win32 no cover terminal_supports_color = True