How to use the termcolor.termcolor function in termcolor

To help you get started, we’ve selected a few termcolor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ParaToolsInc / taucmdr / packages / texttable / __init__.py View on Github external
line = self._splitit(line, isheader)
        space = " "
        out = ""
        for i in range(len(line[0])):
            if self._has_border():
                out += "%s " % self._char_vert
            length = 0
            for cell, width, align in zip(line, self._width, self._align):
                length += 1
                cell_line = cell[i]
                fill = width - len(cell_line)
                if isheader:
                    align = "c"
                    if sys.stdout.isatty():
                        cell_line = termcolor.colored(cell_line, attrs=["bold"])
                if align == "r":
                    out += "%s " % (fill * space + cell_line)
                elif align == "c":
                    out += "%s " % (int(fill / 2) * space + cell_line
                                    + int(fill / 2 + fill % 2) * space)
                else:
                    out += "%s " % (cell_line + fill * space)
                if length < len(line):
                    out += "%s " % [space, self._char_vert][self._has_vlines()]
            out += "%s\n" % ['', self._char_vert][self._has_border()]
        return out
github ParaToolsInc / taucmdr / packages / taucmdr / logger.py View on Github external
* on_magenta
            * on_cyan
            * on_white

        Attributes:
            * bold
            * dark
            * underline
            * blink
            * reverse
            * concealed

        .. _termcolor: http://pypi.python.org/pypi/termcolor
        """
        if self.allow_colors and color_args:
            return termcolor.colored(text, *color_args)
        return text
github ParaToolsInc / taucmdr / packages / taucmdr / util.py View on Github external
def color_text(text, *args, **kwargs):
    """Use :any:`termcolor.colored` to colorize text.

    Args:
        text (str): Text to colorize.
        *args: Positional arguments to pass to :any:`termcolor.colored`.
        **kwargs: Keyword arguments to pass to :any:`termcolor.colored`.

    Returns:
        str: The colorized text.
    """
    if sys.stdout.isatty():
        return termcolor.colored(text, *args, **kwargs)
    return text
github ParaToolsInc / taucmdr / packages / taucmdr / util.py View on Github external
def color_text(text, *args, **kwargs):
    """Use :any:`termcolor.colored` to colorize text.

    Args:
        text (str): Text to colorize.
        *args: Positional arguments to pass to :any:`termcolor.colored`.
        **kwargs: Keyword arguments to pass to :any:`termcolor.colored`.

    Returns:
        str: The colorized text.
    """
    if sys.stdout.isatty():
        return termcolor.colored(text, *args, **kwargs)
    return text
github ParaToolsInc / taucmdr / packages / taucmdr / logger.py View on Github external
* on_magenta
            * on_cyan
            * on_white

        Attributes:
            * bold
            * dark
            * underline
            * blink
            * reverse
            * concealed
        
        .. _termcolor: http://pypi.python.org/pypi/termcolor
        """
        if self.allow_colors and color_args:
            return termcolor.colored(text, *color_args)
        else:
            return text