当前位置: 首页>>代码示例>>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;未经允许,请勿转载。