From 09aeb21dbdbc7b6016daa3d9ee277d7050abb7d4 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Fri, 7 Feb 2020 06:12:14 -0500 Subject: Removed unnecessary methods from fg and bg color enums --- cmd2/ansi.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'cmd2/ansi.py') diff --git a/cmd2/ansi.py b/cmd2/ansi.py index 013aa107..98b98726 100644 --- a/cmd2/ansi.py +++ b/cmd2/ansi.py @@ -50,20 +50,11 @@ class fg(Enum): bright_white = Fore.LIGHTWHITE_EX reset = Fore.RESET - def __str__(self) -> str: - """Make the value the string representation instead of the enum name.""" - return self.value - @staticmethod def colors() -> List[str]: """Return a list of color names.""" return [color.name for color in fg] - @staticmethod - def get_value(name: str) -> str: - """Retrieve color code by name string.""" - return fg[name].value - # Background colors # noinspection PyPep8Naming,DuplicatedCode @@ -88,20 +79,11 @@ class bg(Enum): bright_white = Back.LIGHTWHITE_EX reset = Back.RESET - def __str__(self) -> str: - """Make the value the string representation instead of the enum name.""" - return self.value - @staticmethod def colors() -> List[str]: """Return a list of color names.""" return [color.name for color in bg] - @staticmethod - def get_value(name: str) -> str: - """Retrieve color code by name string.""" - return bg[name].value - FG_RESET = fg.reset.value BG_RESET = bg.reset.value @@ -162,7 +144,7 @@ def fg_lookup(fg_name: Union[str, fg]) -> str: return fg_name.value try: - ansi_escape = fg.get_value(fg_name.lower()) + ansi_escape = fg[fg_name.lower()].value except KeyError: raise ValueError('Foreground color {!r} does not exist; must be one of: {}'.format(fg_name, fg.colors())) return ansi_escape @@ -180,7 +162,7 @@ def bg_lookup(bg_name: Union[str, bg]) -> str: return bg_name.value try: - ansi_escape = bg.get_value(bg_name.lower()) + ansi_escape = bg[bg_name.lower()].value except KeyError: raise ValueError('Background color {!r} does not exist; must be one of: {}'.format(bg_name, bg.colors())) return ansi_escape -- cgit v1.2.1