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

Johannes Bechberger's avatar
Johannes Bechberger committed
6
7

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


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)