本文整理汇总了Python中pygments.plugin.find_plugin_styles方法的典型用法代码示例。如果您正苦于以下问题:Python plugin.find_plugin_styles方法的具体用法?Python plugin.find_plugin_styles怎么用?Python plugin.find_plugin_styles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.plugin
的用法示例。
在下文中一共展示了plugin.find_plugin_styles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_style_by_name
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_styles [as 别名]
def get_style_by_name(name):
if name in STYLE_MAP:
mod, cls = STYLE_MAP[name].split('::')
builtin = "yes"
else:
for found_name, style in find_plugin_styles():
if name == found_name:
return style
# perhaps it got dropped into our styles package
builtin = ""
mod = name
cls = name.title() + "Style"
try:
mod = __import__('pygments.styles.' + mod, None, None, [cls])
except ImportError:
raise ClassNotFound("Could not find style module %r" % mod +
(builtin and ", though it should be builtin") + ".")
try:
return getattr(mod, cls)
except AttributeError:
raise ClassNotFound("Could not find style class %r in style module." % cls)
示例2: get_all_styles
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_styles [as 别名]
def get_all_styles():
"""Return an generator for all styles by name,
both builtin and plugin."""
for name in STYLE_MAP:
yield name
for name, _ in find_plugin_styles():
yield name