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


Python _compat.imap方法代碼示例

本文整理匯總了Python中jinja2._compat.imap方法的典型用法代碼示例。如果您正苦於以下問題:Python _compat.imap方法的具體用法?Python _compat.imap怎麽用?Python _compat.imap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jinja2._compat的用法示例。


在下文中一共展示了_compat.imap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: do_sum

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import imap [as 別名]
def do_sum(environment, iterable, attribute=None, start=0):
    """Returns the sum of a sequence of numbers plus the value of parameter
    'start' (which defaults to 0).  When the sequence is empty it returns
    start.

    It is also possible to sum up only certain attributes:

    .. sourcecode:: jinja

        Total: {{ items|sum(attribute='price') }}

    .. versionchanged:: 2.6
       The `attribute` parameter was added to allow suming up over
       attributes.  Also the `start` parameter was moved on to the right.
    """
    if attribute is not None:
        iterable = imap(make_attrgetter(environment, attribute), iterable)
    return sum(iterable, start) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:20,代碼來源:filters.py

示例2: __init__

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import imap [as 別名]
def __init__(self, names=(), message=None):
        if message is None:
            message = u'none of the templates given were found: ' + \
                      u', '.join(imap(text_type, names))
        TemplateNotFound.__init__(self, names and names[-1] or None, message)
        self.templates = list(names) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:exceptions.py

示例3: _fail_ut_eof

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import imap [as 別名]
def _fail_ut_eof(self, name, end_token_stack, lineno):
        expected = []
        for exprs in end_token_stack:
            expected.extend(imap(describe_token_expr, exprs))
        if end_token_stack:
            currently_looking = ' or '.join(
                "'%s'" % describe_token_expr(expr)
                for expr in end_token_stack[-1])
        else:
            currently_looking = None

        if name is None:
            message = ['Unexpected end of template.']
        else:
            message = ['Encountered unknown tag \'%s\'.' % name]

        if currently_looking:
            if name is not None and name in expected:
                message.append('You probably made a nesting mistake. Jinja '
                               'is expecting this tag, but currently looking '
                               'for %s.' % currently_looking)
            else:
                message.append('Jinja was looking for the following tags: '
                               '%s.' % currently_looking)

        if self._tag_stack:
            message.append('The innermost block that needs to be '
                           'closed is \'%s\'.' % self._tag_stack[-1])

        self.fail(' '.join(message), lineno) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:32,代碼來源:parser.py


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