本文整理汇总了Python中pygments.plugin.find_plugin_formatters方法的典型用法代码示例。如果您正苦于以下问题:Python plugin.find_plugin_formatters方法的具体用法?Python plugin.find_plugin_formatters怎么用?Python plugin.find_plugin_formatters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.plugin
的用法示例。
在下文中一共展示了plugin.find_plugin_formatters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_formatter_for_filename
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_formatters [as 别名]
def get_formatter_for_filename(fn, **options):
"""Lookup and instantiate a formatter by filename pattern.
Raises ClassNotFound if not found.
"""
fn = basename(fn)
for modname, name, _, filenames, _ in itervalues(FORMATTERS):
for filename in filenames:
if _fn_matches(fn, filename):
if name not in _formatter_cache:
_load_formatters(modname)
return _formatter_cache[name](**options)
for cls in find_plugin_formatters():
for filename in cls.filenames:
if _fn_matches(fn, filename):
return cls(**options)
raise ClassNotFound("no formatter found for file name %r" % fn)
示例2: get_formatter_for_filename
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_formatters [as 别名]
def get_formatter_for_filename(fn, **options):
"""Lookup and instantiate a formatter by filename pattern.
Raises ClassNotFound if not found.
"""
fn = basename(fn)
for modname, name, _, filenames, _ in FORMATTERS.values():
for filename in filenames:
if _fn_matches(fn, filename):
if name not in _formatter_cache:
_load_formatters(modname)
return _formatter_cache[name](**options)
for cls in find_plugin_formatters():
for filename in cls.filenames:
if _fn_matches(fn, filename):
return cls(**options)
raise ClassNotFound("no formatter found for file name %r" % fn)
示例3: get_all_formatters
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_formatters [as 别名]
def get_all_formatters():
"""Return a generator for all formatter classes."""
# NB: this returns formatter classes, not info like get_all_lexers().
for info in itervalues(FORMATTERS):
if info[1] not in _formatter_cache:
_load_formatters(info[0])
yield _formatter_cache[info[1]]
for _, formatter in find_plugin_formatters():
yield formatter
示例4: find_formatter_class
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_formatters [as 别名]
def find_formatter_class(alias):
"""Lookup a formatter by alias.
Returns None if not found.
"""
for module_name, name, aliases, _, _ in itervalues(FORMATTERS):
if alias in aliases:
if name not in _formatter_cache:
_load_formatters(module_name)
return _formatter_cache[name]
for _, cls in find_plugin_formatters():
if alias in cls.aliases:
return cls
示例5: get_all_formatters
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_formatters [as 别名]
def get_all_formatters():
"""Return a generator for all formatter classes."""
# NB: this returns formatter classes, not info like get_all_lexers().
for info in FORMATTERS.values():
if info[1] not in _formatter_cache:
_load_formatters(info[0])
yield _formatter_cache[info[1]]
for _, formatter in find_plugin_formatters():
yield formatter
示例6: find_formatter_class
# 需要导入模块: from pygments import plugin [as 别名]
# 或者: from pygments.plugin import find_plugin_formatters [as 别名]
def find_formatter_class(alias):
"""Lookup a formatter by alias.
Returns None if not found.
"""
for module_name, name, aliases, _, _ in FORMATTERS.values():
if alias in aliases:
if name not in _formatter_cache:
_load_formatters(module_name)
return _formatter_cache[name]
for _, cls in find_plugin_formatters():
if alias in cls.aliases:
return cls