X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=ansi.py;h=1633fddbcb31714d3ae7342daca37c1c4034b4c6;hb=19ca9f7213d41111b22147908e17bd3ead306945;hp=6897291ba252f91c866b967cd18e0aa13f0f151d;hpb=971d4ba141459f78d10d5770b9459d1ead7d49a0;p=python_utils.git diff --git a/ansi.py b/ansi.py index 6897291..1633fdd 100755 --- a/ansi.py +++ b/ansi.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 -from abc import abstractmethod import difflib import io import logging import re import sys +from abc import abstractmethod from typing import Any, Callable, Dict, Iterable, Optional, Tuple from overrides import overrides @@ -1776,9 +1776,7 @@ def fg( if (is_16color(red) and is_16color(green) and is_16color(blue)) or force_16color: logger.debug("Using 16-color strategy") return fg_16color(red, green, blue) - if ( - is_216color(red) and is_216color(green) and is_216color(blue) - ) or force_216color: + if (is_216color(red) and is_216color(green) and is_216color(blue)) or force_216color: logger.debug("Using 216-color strategy") return fg_216color(red, green, blue) logger.debug("Using 24-bit color strategy") @@ -1838,6 +1836,7 @@ def guess_name(name: str) -> str: return best_guess +@logging_utils.squelch_repeated_log_messages(1) def bg( name: Optional[str] = "", red: Optional[int] = None, @@ -1879,9 +1878,7 @@ def bg( if (is_16color(red) and is_16color(green) and is_16color(blue)) or force_16color: logger.debug("Using 16-color strategy") return bg_16color(red, green, blue) - if ( - is_216color(red) and is_216color(green) and is_216color(blue) - ) or force_216color: + if (is_216color(red) and is_216color(green) and is_216color(blue)) or force_216color: logger.debug("Using 216-color strategy") return bg_216color(red, green, blue) logger.debug("Using 24-bit color strategy") @@ -1938,9 +1935,6 @@ if __name__ == '__main__': _ = pick_contrasting_color(possibility) xf = fg(None, _[0], _[1], _[2]) xb = bg(None, _[0], _[1], _[2]) - print( - f'{f}{xb}{possibility}{reset()}\t\t\t' - f'{b}{xf}{possibility}{reset()}' - ) + print(f'{f}{xb}{possibility}{reset()}\t\t\t' f'{b}{xf}{possibility}{reset()}') main()