utils.py 649 Bytes
Newer Older
Johannes Bechberger's avatar
Johannes Bechberger committed
1 2 3 4 5
import logging
from os import path
import sys

def get_mjtest_basedir() -> str:
6
    return path.dirname(path.dirname(path.dirname(path.realpath(__file__))))
Johannes Bechberger's avatar
Johannes Bechberger committed
7 8


9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
def colored(text: str, *args, **kwargs):
    """
    Wrapper around termcolor.colored (if it's loadable)
    """
    try:
        from termcolor import colored
        return colored(text, *args, **kwargs)
    except ImportError:
        return text


def cprint(text: str, *args, **kwargs):
    """
    Wrapper around termcolor.cprint (if it's loadable)
    """
    try:
        from termcolor import cprint
        cprint(text, *args, **kwargs)
    except ImportError:
        print(text)