-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Execution] Use colors to improve output readability (#63)
- Loading branch information
Showing
2 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from typing import Dict | ||
|
||
|
||
class _Colors: | ||
Blue = "\033[34m" | ||
Cyan = "\033[36m" | ||
Green = "\033[32m" | ||
Red = "\033[31m" | ||
Yellow = "\033[33m" | ||
|
||
Bold = "\033[1m" | ||
Reset = "\033[0m" | ||
|
||
|
||
def print_cyan(message: str, **kwargs) -> None: | ||
_print_colored(message, _Colors.Cyan, kwargs) | ||
|
||
|
||
def print_blue(message: str, **kwargs) -> None: | ||
_print_colored(message, _Colors.Blue, kwargs) | ||
|
||
|
||
def print_green(message: str, **kwargs) -> None: | ||
_print_colored(message, _Colors.Green, kwargs) | ||
|
||
|
||
def print_red(message: str, **kwargs) -> None: | ||
_print_colored(message, _Colors.Red, kwargs) | ||
|
||
|
||
def print_yellow(message: str, **kwargs) -> None: | ||
_print_colored(message, _Colors.Yellow, kwargs) | ||
|
||
|
||
def print_bold(message: str, **kwargs) -> None: | ||
_print_colored(message, _Colors.Bold, kwargs) | ||
|
||
|
||
def _print_colored(message: str, color: str, kwargs: Dict) -> None: | ||
if "bold" in kwargs: | ||
if kwargs["bold"]: | ||
color += _Colors.Bold | ||
del kwargs["bold"] | ||
print(f"{color}{message}{_Colors.Reset}", **kwargs) |