From d0866e9bcbd9794255f1825c1f67e1ce9112f7d2 Mon Sep 17 00:00:00 2001 From: Sidney Kochman Date: Tue, 11 Aug 2020 15:19:46 -0400 Subject: [PATCH] fix termutils (#8) --- src/replit/termutils.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/replit/termutils.py b/src/replit/termutils.py index c287b8b..dc42f4f 100644 --- a/src/replit/termutils.py +++ b/src/replit/termutils.py @@ -1,6 +1,7 @@ """Pure Python ANSI Color Escape Code generator.""" import colorsys + def clear() -> None: """Clear the terminal.""" print("\033[H\033[2J", end="", flush=True) @@ -70,16 +71,16 @@ class Color: Returns: color : RGB colors from Hex Value - """ - try: - r, g, b = colorsys.hsv_to_rgb(h, s, v) + """ + try: + r, g, b = colorsys.hsv_to_rgb(h, s, v) except: - raise ValueError('Converting HSV to RGB ran into an error') - + raise ValueError("Converting HSV to RGB ran into an error") + return cls(r, g, b) - + @classmethod - def hls(cls, h, l, s) + def hls(cls, h, l, s): """ Convert Hex Value to RGB then generate an ANSI escape code @@ -92,14 +93,15 @@ class Color: Returns: color : RGB colors from Hex Value - """ - try: - r, g, b = colorsys.hls_to_rgb(h, s, v) + """ + try: + r, g, b = colorsys.hls_to_rgb(h, s, v) except: - raise ValueError('Converting HLS to RGB ran into an error') - + raise ValueError("Converting HLS to RGB ran into an error") + return cls(r, g, b) + class Bit: def __init__(self, value: int) -> None: """