From 27c55999c61b8e886f040eaf759c1411c0574121 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 3 Nov 2023 11:05:09 +0100 Subject: [PATCH] gen/common/colorer: Add enable parameter to allow enabling/disabling coloring. --- litex/gen/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litex/gen/common.py b/litex/gen/common.py index 3a963fff6..101243038 100644 --- a/litex/gen/common.py +++ b/litex/gen/common.py @@ -8,7 +8,7 @@ from migen import * # Coloring Helpers --------------------------------------------------------------------------------- -def colorer(s, color="bright"): +def colorer(s, color="bright", enable=True): """Apply ANSI colors to a string.""" header = { "bright": "\x1b[1m", @@ -18,7 +18,7 @@ def colorer(s, color="bright"): "yellow": "\x1b[33m", "underline": "\x1b[4m"}[color] trailer = "\x1b[0m" - return header + str(s) + trailer + return (header + str(s) + trailer) if enable else str(s) # Bit/Bytes Reversing ------------------------------------------------------------------------------