python类Terminal256Formatter()的实例源码

style_transfer.py 文件源码 项目:style_transfer 作者: crowsonkb 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def print_args():
    """Prints out all command-line parameters."""
    bg = terminal_bg()
    if bg is True:
        style = 'xcode'
    elif bg is False:
        style = 'monokai'

    pprint = print_
    try:
        if bg is not None:
            import pygments
            from pygments.lexers import Python3Lexer
            from pygments.formatters import Terminal256Formatter
            pprint = partial(pygments.highlight, lexer=Python3Lexer(),
                             formatter=Terminal256Formatter(style=style), outfile=sys.stdout)
    except ImportError:
        pass
    print_('Parameters:')
    for key in sorted(ARGS):
        v = repr(getattr(ARGS, key))
        print_('% 14s: ' % key, end='')
        pprint(v)
    print_()
ddquery.py 文件源码 项目:ddquery 作者: elinaldosoft 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        self.highlight = kwargs.pop('highlight', True)
        self.style = kwargs.pop('style', 'default')

        self.parse = kwargs.pop('parse', True)
        self.reindent = kwargs.pop('reindent', True)
        self.keyword_case = kwargs.pop('keyword_case', 'upper')

        self._lexer = SqlLexer()
        self._formatter = Terminal256Formatter(style=self.style)

        super(SqlFormatter, self).__init__(*args, **kwargs)
tasks.py 文件源码 项目:pinder 作者: dotwaffle 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def pprint_color(obj):
    print highlight(pformat(obj), PythonLexer(), Terminal256Formatter(style='trac'))
formatter.py 文件源码 项目:microProxy 作者: mike820324 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def colorize(lexer_name, raw_text):  # pragma: no cover
    lexer = get_lexer_by_name(lexer_name, stripall=True)
    formatter = Terminal256Formatter()
    return highlight(raw_text, lexer, formatter)
show_code.py 文件源码 项目:lddmm-ot 作者: jeanfeydy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def show_code(func):
    if type(func) is str :
        code = func
    else :
        code = inspect.getsourcelines(func)[0]
        code = ''.join(code)
    print(highlight(code, PythonLexer(), Terminal256Formatter()))
syntax_highlight.py 文件源码 项目:Price-Comparator 作者: Thejas-1 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def help_highlight(string):
        return highlight(string, HelpLexer(), Terminal256Formatter(style='monokai'))
syntax_highlight.py 文件源码 项目:Price-Comparator 作者: Thejas-1 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def python_highlight(string):
        return highlight(string, PythonLexer(encoding="Utf-8"),
                         Terminal256Formatter(style='monokai',
                                              encoding="Utf-8"))
emitting.py 文件源码 项目:deb-python-dcos 作者: openstack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _highlight_json(json_value):
    """
    :param json_value: JSON value to syntax-highlight
    :type json_value: dict, list, number, string, boolean, or None
    :returns: A string representation of the supplied JSON value,
              highlighted for a terminal that supports ANSI colors.
    :rtype: str
    """

    return pygments.highlight(
        json_value, JsonLexer(), Terminal256Formatter()).strip()
tbv.py 文件源码 项目:tbvaccine 作者: skorokithakis 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _process_var_line(self, line):
        """
        Process a line of variables in the traceback.
        """
        if self._show_vars is False or (self._isolate and not self._file_in_dir()):
            # Don't print.
            return False
        else:
            line = highlight(line, PythonLexer(), TerminalFormatter(style="monokai"))
            self._print(line.rstrip("\r\n"), max_length=self._max_length)
        return True
tbv.py 文件源码 项目:tbvaccine 作者: skorokithakis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _process_code_line(self, line):
        """
        Process a line of code in the traceback.
        """
        if self._isolate and not self._file_in_dir():
            # Print without colors.
            self._print(line)
        else:
            if self._isolate:
                line = line[1:]
                self._print(">", fg="red", style="bright")
            line = highlight(line, PythonLexer(), TerminalFormatter(style="monokai"))
            self._print(line.rstrip("\r\n"))
emitting.py 文件源码 项目:deploy-marathon-bluegreen 作者: softonic 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _highlight_json(json_value):
    """
    :param json_value: JSON value to syntax-highlight
    :type json_value: dict, list, number, string, boolean, or None
    :returns: A string representation of the supplied JSON value,
              highlighted for a terminal that supports ANSI colors.
    :rtype: str
    """

    return pygments.highlight(
        json_value, JsonLexer(), Terminal256Formatter()).strip()


问题


面经


文章

微信
公众号

扫码关注公众号