本文整理匯總了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