本文整理汇总了Python中pygments.formatters.terminal256.Terminal256Formatter方法的典型用法代码示例。如果您正苦于以下问题:Python terminal256.Terminal256Formatter方法的具体用法?Python terminal256.Terminal256Formatter怎么用?Python terminal256.Terminal256Formatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.formatters.terminal256
的用法示例。
在下文中一共展示了terminal256.Terminal256Formatter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_packets
# 需要导入模块: from pygments.formatters import terminal256 [as 别名]
# 或者: from pygments.formatters.terminal256 import Terminal256Formatter [as 别名]
def print_packets(path: list, nodes: dict) -> None:
tokens = []
for e in path[:-1]:
node = nodes[e.dst]
p = node.render()
line = '{} = {}'.format(node.name.replace('-', '_'), repr(p))
tokens.extend(list(pygments.lex(line, lexer=Python3Lexer())))
# p = self.fuzz_node.render()
node = nodes[path[-1].dst]
p = node.render()
line = '{} = {}'.format(node.name.replace('-', '_'), repr(p))
print(pygments.highlight(line, Python3Lexer(), Terminal256Formatter(style='rrt')))
# tokens.extend(list(pygments.lex(line, lexer=Python3Lexer())))
# style = style_from_pygments_cls(get_style_by_name('colorful'))
# print_formatted_text(PygmentsTokens(tokens), style=style)
# --------------------------------------------------------------- #
示例2: traceback_highlighter_factory
# 需要导入模块: from pygments.formatters import terminal256 [as 别名]
# 或者: from pygments.formatters.terminal256 import Terminal256Formatter [as 别名]
def traceback_highlighter_factory() -> Callable[[str], str]: # pragma: no cover
from pygments.lexers.python import PythonTracebackLexer
lexer = PythonTracebackLexer()
from pygments.formatters.terminal256 import Terminal256Formatter
formatter = Terminal256Formatter(style='native')
def inner(tb):
return highlight(tb, lexer, formatter)
from pygments import highlight
return inner
示例3: print_python
# 需要导入模块: from pygments.formatters import terminal256 [as 别名]
# 或者: from pygments.formatters.terminal256 import Terminal256Formatter [as 别名]
def print_python(path: list) -> None:
tokens = []
block_code = path_to_python(path)
print(pygments.highlight(block_code, Python3Lexer(), Terminal256Formatter(style='rrt')))
# tokens.extend(list(pygments.lex(block_code, lexer=Python3Lexer())))
# print_formatted_text(PygmentsTokens(tokens))
# --------------------------------------------------------------- #
示例4: print_poc
# 需要导入模块: from pygments.formatters import terminal256 [as 别名]
# 或者: from pygments.formatters.terminal256 import Terminal256Formatter [as 别名]
def print_poc(target: Target, path: list,
receive_data_after_each_request, receive_data_after_fuzz) -> None:
tokens = []
exploit_code = get_exploit_code(target, path, receive_data_after_each_request, receive_data_after_fuzz)
print(pygments.highlight(exploit_code, Python3Lexer(), Terminal256Formatter(style='rrt')))
# tokens.extend(list(pygments.lex(exploit_code, lexer=Python3Lexer())))
# print_formatted_text(PygmentsTokens(tokens))
# --------------------------------------------------------------- #