当前位置: 首页>>代码示例>>Python>>正文


Python lexers.Python3Lexer方法代码示例

本文整理汇总了Python中pygments.lexers.Python3Lexer方法的典型用法代码示例。如果您正苦于以下问题:Python lexers.Python3Lexer方法的具体用法?Python lexers.Python3Lexer怎么用?Python lexers.Python3Lexer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygments.lexers的用法示例。


在下文中一共展示了lexers.Python3Lexer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printargs

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def printargs():
    """Prints out all command-line parameters."""
    switch = {BGColor.LIGHT: 'xcode',
              BGColor.DARK: 'vim',
              BGColor.UNKNOWN: 'default'}
    style = switch[terminal_bg()]
    pprint = print
    try:
        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('% 16s: ' % key, end='')
        pprint(v)
    print() 
开发者ID:crowsonkb,项目名称:style_transfer,代码行数:24,代码来源:style_transfer.py

示例2: __init__

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def __init__(self, data):
        # Logger
        self.logger = Log()
        # Max ID
        self.max_id = 10 * 10 * 10
        # Get tokens
        self.logger.log('Getting tokens from file...')
        self._tokens = list(Python3Lexer().get_tokens(data))
        # Tokenize
        self._tokenize()

    # Get token by id 
开发者ID:PyObfx,项目名称:PyObfx,代码行数:14,代码来源:tokenizer.py

示例3: __init__

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def __init__(self, parent, lexer=None):
        super(PygmentsHighlighter, self).__init__(parent)

        self._document = self.document()
        self._formatter = HtmlFormatter(nowrap=True)
        self.set_style('default')
        if lexer is not None:
            self._lexer = lexer
        else:
            if PY3:
                self._lexer = Python3Lexer()
            else:
                self._lexer = PythonLexer() 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:15,代码来源:pygments_highlighter.py

示例4: lexer3

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def lexer3():
    yield Python3Lexer() 
开发者ID:pygments,项目名称:pygments,代码行数:4,代码来源:test_python.py

示例5: test_others_work

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def test_others_work():
    """Check other formatters don't crash."""
    highlight(CODE, Python3Lexer(), LatexFormatter(style=MyStyle))
    highlight(CODE, Python3Lexer(), HtmlFormatter(style=MyStyle)) 
开发者ID:pygments,项目名称:pygments,代码行数:6,代码来源:test_terminal_formatter.py

示例6: test_256esc_seq

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def test_256esc_seq():
    """
    Test that a few escape sequences are actually used when using ansi<> color
    codes.
    """
    def termtest(x):
        return highlight(x, Python3Lexer(),
                         Terminal256Formatter(style=MyStyle))

    assert '32;101' in termtest('0x123')
    assert '92;42' in termtest('123')
    assert '90' in termtest('#comment')
    assert '94;41' in termtest('"String"') 
开发者ID:pygments,项目名称:pygments,代码行数:15,代码来源:test_terminal_formatter.py

示例7: render

# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import Python3Lexer [as 别名]
def render(self, *args, **kwargs):
        from pygments import highlight
        from pygments.lexers import Python3Lexer
        from pygments.formatters import HtmlFormatter
        code = render_output(self.item, self.pprint.pformat)
        formatter = HtmlFormatter(noclasses=True)
        formatter.style.background_color = 'transparent'
        return _format_output(highlight(code, Python3Lexer(), formatter)) 
开发者ID:vinci1it2000,项目名称:schedula,代码行数:10,代码来源:__init__.py


注:本文中的pygments.lexers.Python3Lexer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。