Skip to content

Commit 204f4ce

Browse files
committed
allow colorize to use color codes
Signed-off-by: Zen <[email protected]>
1 parent cedd156 commit 204f4ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/zenlib/util/colorize.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.1"
1+
__version__ = "0.2.0"
22

33
from enum import Enum
44

@@ -29,5 +29,9 @@ def __str__(self):
2929

3030

3131
def colorize(text: str, color="white", bright=False, bold=False) -> str:
32-
color_code = Colors[color.upper()].value
32+
try:
33+
color_code = Colors[color.upper()].value
34+
except (KeyError, AttributeError):
35+
color_code = int(color)
36+
3337
return f"{ANSICode(color_code, bright, bold)}{text}{ANSICode(0)}"

0 commit comments

Comments
 (0)