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


Python _compat.iteritems方法代碼示例

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


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

示例1: do_urlencode

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def do_urlencode(value):
    """Escape strings for use in URLs (uses UTF-8 encoding).  It accepts both
    dictionaries and regular strings as well as pairwise iterables.

    .. versionadded:: 2.7
    """
    itemiter = None
    if isinstance(value, dict):
        itemiter = iteritems(value)
    elif not isinstance(value, string_types):
        try:
            itemiter = iter(value)
        except TypeError:
            pass
    if itemiter is None:
        return unicode_urlencode(value)
    return u'&'.join(unicode_urlencode(k) + '=' +
                     unicode_urlencode(v, for_qs=True)
                     for k, v in itemiter) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:21,代碼來源:filters.py

示例2: branch_update

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def branch_update(self, branch_symbols):
        stores = {}
        for branch in branch_symbols:
            for target in branch.stores:
                if target in self.stores:
                    continue
                stores[target] = stores.get(target, 0) + 1

        for sym in branch_symbols:
            self.refs.update(sym.refs)
            self.loads.update(sym.loads)
            self.stores.update(sym.stores)

        for name, branch_count in iteritems(stores):
            if branch_count == len(branch_symbols):
                continue
            target = self.find_ref(name)
            assert target is not None, 'should not happen'

            if self.parent is not None:
                outer_target = self.parent.find_ref(name)
                if outer_target is not None:
                    self.loads[target] = (VAR_LOAD_ALIAS, outer_target)
                    continue
            self.loads[target] = (VAR_LOAD_RESOLVE, name) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:27,代碼來源:idtracking.py

示例3: do_xmlattr

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def do_xmlattr(_eval_ctx, d, autospace=True):
    """Create an SGML/XML attribute string based on the items in a dict.
    All values that are neither `none` nor `undefined` are automatically
    escaped:

    .. sourcecode:: html+jinja

        <ul{{ {'class': 'my_list', 'missing': none,
                'id': 'list-%d'|format(variable)}|xmlattr }}>
        ...
        </ul>

    Results in something like this:

    .. sourcecode:: html

        <ul class="my_list" id="list-42">
        ...
        </ul>

    As you can see it automatically prepends a space in front of the item
    if the filter returned something unless the second parameter is false.
    """
    rv = u' '.join(
        u'%s="%s"' % (escape(key), escape(value))
        for key, value in iteritems(d)
        if value is not None and not isinstance(value, Undefined)
    )
    if autospace and rv:
        rv = u' ' + rv
    if _eval_ctx.autoescape:
        rv = Markup(rv)
    return rv 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:35,代碼來源:filters.py

示例4: dump_param_targets

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def dump_param_targets(self):
        rv = set()
        node = self
        while node is not None:
            for target, (instr, _) in iteritems(self.loads):
                if instr == VAR_LOAD_PARAMETER:
                    rv.add(target)
            node = node.parent
        return rv 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:idtracking.py

示例5: list_templates

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def list_templates(self):
        result = []
        for prefix, loader in iteritems(self.mapping):
            for template in loader.list_templates():
                result.append(prefix + self.delimiter + template)
        return result 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:loaders.py

示例6: enter_frame

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def enter_frame(self, frame):
        """Remember all undeclared identifiers."""
        CodeGenerator.enter_frame(self, frame)
        for _, (action, param) in iteritems(frame.symbols.loads):
            if action == 'resolve':
                self.undeclared_identifiers.add(param) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:meta.py

示例7: get_jinja_locals

# 需要導入模塊: from jinja2 import _compat [as 別名]
# 或者: from jinja2._compat import iteritems [as 別名]
def get_jinja_locals(real_locals):
    ctx = real_locals.get('context')
    if ctx:
        locals = ctx.get_all().copy()
    else:
        locals = {}

    local_overrides = {}

    for name, value in iteritems(real_locals):
        if not name.startswith('l_') or value is missing:
            continue
        try:
            _, depth, name = name.split('_', 2)
            depth = int(depth)
        except ValueError:
            continue
        cur_depth = local_overrides.get(name, (-1,))[0]
        if cur_depth < depth:
            local_overrides[name] = (depth, value)

    for name, (_, value) in iteritems(local_overrides):
        if value is missing:
            locals.pop(name, None)
        else:
            locals[name] = value

    return locals 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:30,代碼來源:debug.py


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