Source code for kwcoco.util.util_rich

"""
from __future__ import annotations

Deprecated: use the one in kwutil instead
"""

try:
    from functools import cache
except ImportError:
    #TODO: remove when python 3.9 is the minimu and just use functools.cache
    from ubelt import memoize as cache # type: ignore


[docs] @cache def _get_rich_print(): try: import rich except ImportError: return print else: return rich.print
[docs] def rich_print(*args, **kwargs): """ Does a rich print if available, otherwise fallback to regular print """ print_func = _get_rich_print() print_func(*args, **kwargs)