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