當前位置: 首頁>>代碼示例>>Python>>正文


Python plugin.find_plugin_formatters方法代碼示例

本文整理匯總了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) 
開發者ID:joxeankoret,項目名稱:pigaios,代碼行數:19,代碼來源:__init__.py

示例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) 
開發者ID:pygments,項目名稱:pygments,代碼行數:19,代碼來源:__init__.py

示例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 
開發者ID:joxeankoret,項目名稱:pigaios,代碼行數:11,代碼來源:__init__.py

示例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 
開發者ID:joxeankoret,項目名稱:pigaios,代碼行數:15,代碼來源:__init__.py

示例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 
開發者ID:pygments,項目名稱:pygments,代碼行數:11,代碼來源:__init__.py

示例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 
開發者ID:pygments,項目名稱:pygments,代碼行數:15,代碼來源:__init__.py


注:本文中的pygments.plugin.find_plugin_formatters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。