gen/common/colorer: Add enable parameter to allow enabling/disabling coloring.
This commit is contained in:
parent
1f200c83f3
commit
27c55999c6
|
@ -8,7 +8,7 @@ from migen import *
|
||||||
|
|
||||||
# Coloring Helpers ---------------------------------------------------------------------------------
|
# Coloring Helpers ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
def colorer(s, color="bright"):
|
def colorer(s, color="bright", enable=True):
|
||||||
"""Apply ANSI colors to a string."""
|
"""Apply ANSI colors to a string."""
|
||||||
header = {
|
header = {
|
||||||
"bright": "\x1b[1m",
|
"bright": "\x1b[1m",
|
||||||
|
@ -18,7 +18,7 @@ def colorer(s, color="bright"):
|
||||||
"yellow": "\x1b[33m",
|
"yellow": "\x1b[33m",
|
||||||
"underline": "\x1b[4m"}[color]
|
"underline": "\x1b[4m"}[color]
|
||||||
trailer = "\x1b[0m"
|
trailer = "\x1b[0m"
|
||||||
return header + str(s) + trailer
|
return (header + str(s) + trailer) if enable else str(s)
|
||||||
|
|
||||||
# Bit/Bytes Reversing ------------------------------------------------------------------------------
|
# Bit/Bytes Reversing ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue