Python colorama 模块,Style() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用colorama.Style()

项目:incubator-ariatosca    作者:apache    | 项目源码 | 文件源码
def __repr__(self):
        if self._color_spec:
            return '{schema}{str}{reset}'.format(
                schema=self._color_spec, str=safe_str(self._str), reset=Colors.Style.RESET_ALL)
        return self._str
项目:incubator-ariatosca    作者:apache    | 项目源码 | 文件源码
def highlight(self, pattern, schema):
        if pattern is None:
            return
        for match in set(re.findall(re.compile(pattern), self._str)):
            self.replace(match, schema + match + Colors.Style.RESET_ALL + self._color_spec)
项目:therapist    作者:rehandalal    | 项目源码 | 文件源码
def output(message, **kwargs):
    def repl(match):  # pragma: no cover
        attr = match.group(0)[2:-1].upper()
        if hasattr(colorama.Fore, attr):
            return getattr(colorama.Fore, attr)
        elif hasattr(colorama.Style, attr):
            return getattr(colorama.Style, attr)
        else:
            return match.group(0)

    message, count = re.subn('#{(.+?)}', repl, message)
    message = colorama.Style.RESET_ALL + message + colorama.Style.RESET_ALL
    print_(message, **kwargs)
项目:pipenv    作者:pypa    | 项目源码 | 文件源码
def color_str(self):
        style = 'BRIGHT' if self.bold else 'NORMAL'
        c = '%s%s%s%s%s' % (getattr(colorama.Fore, self.color), getattr(colorama.Style, style), self.s, colorama.Fore.RESET, getattr(colorama.Style, 'NORMAL'))

        if self.always_color:
            return c
        elif sys.stdout.isatty() and not DISABLE_COLOR:
            return c
        else:
            return self.s
项目:TLCS-900    作者:Victorious3    | 项目源码 | 文件源码
def print_c(*args):
    print(*args, end = Style.RESET_ALL)
项目:TLCS-900    作者:Victorious3    | 项目源码 | 文件源码
def finalize():
    term.finalize()

    set_cursor(True)

    # Reset colors and style
    print_raw(Style.RESET_ALL)
项目:grako    作者:apalala    | 项目源码 | 文件源码
def init():
    try:
        import colorama

        global Fore, Back, Style
        Fore = colorama.Fore
        Back = colorama.Back
        Style = colorama.Style
        colorama.Fore
    except ImportError:
        pass