global wrapped_stdout, wrapped_stderr
wrapped_stdout = None
wrapped_stderr = None
global atexit_done
atexit_done = False
global fixed_windows_console
fixed_windows_console = False
try: # no-op if it wasn't registered
atexit.unregister(reset_all) except AttributeError: # python 2: no atexit.unregister. Oh well, we did our best. pass
def reset_all(): if AnsiToWin32 isnotNone: # Issue #74: objects might become None at exit
AnsiToWin32(orig_stdout).reset_all()
global atexit_done ifnot atexit_done:
atexit.register(reset_all)
atexit_done = True
def deinit(): if orig_stdout isnotNone:
sys.stdout = orig_stdout if orig_stderr isnotNone:
sys.stderr = orig_stderr
def just_fix_windows_console(): global fixed_windows_console
if sys.platform != "win32": return if fixed_windows_console: return if wrapped_stdout isnotNoneor wrapped_stderr isnotNone: # Someone already ran init() and it did stuff, so we won't second-guess them return
# On newer versions of Windows, AnsiToWin32.__init__ will implicitly enable the # native ANSI support in the console as a side-effect. We only need to actually # replace sys.stdout/stderr if we're in the old-style conversion mode.
new_stdout = AnsiToWin32(sys.stdout, convert=None, strip=None, autoreset=False) if new_stdout.convert:
sys.stdout = new_stdout
new_stderr = AnsiToWin32(sys.stderr, convert=None, strip=None, autoreset=False) if new_stderr.convert:
sys.stderr = new_stderr
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.