mirror of
https://github.com/Alex38Lyon/Synthese-PSM_LARRA.git
synced 2026-11-29 19:58:36 +00:00
update
This commit is contained in:
1 parent
3e7ab1a7e2
commit
b0635fa62b
3 files changed
+104
-2
No files matched your search
@@ -90,8 +90,35 @@ class Colors:
|
||||
UNDERLINE = "\033[4m"
|
||||
|
||||
|
||||
#################################################################################################
|
||||
class AnsiStrippingStream:
|
||||
"""Supprime les codes ANSI des sorties en mode non interactif."""
|
||||
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
|
||||
def write(self, text):
|
||||
return self.stream.write(strip_ansi_codes(text))
|
||||
|
||||
def flush(self):
|
||||
return self.stream.flush()
|
||||
|
||||
def isatty(self):
|
||||
return self.stream.isatty()
|
||||
|
||||
def fileno(self):
|
||||
return self.stream.fileno()
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.stream, name)
|
||||
|
||||
|
||||
INTERACTIF = sys.stdout.isatty() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "dumb"
|
||||
|
||||
if not INTERACTIF:
|
||||
sys.stdout = AnsiStrippingStream(sys.stdout)
|
||||
sys.stderr = AnsiStrippingStream(sys.stderr)
|
||||
|
||||
|
||||
#################################################################################################
|
||||
# Formatter pour la console avec couleurs
|
||||
|
||||
Reference in new issue
Block a user