当前位置: 首页>>代码示例>>Python>>正文


Python utils.viewitems方法代码示例

本文整理汇总了Python中future.utils.viewitems方法的典型用法代码示例。如果您正苦于以下问题:Python utils.viewitems方法的具体用法?Python utils.viewitems怎么用?Python utils.viewitems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在future.utils的用法示例。


在下文中一共展示了utils.viewitems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_init_flt

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def get_init_flt(dbase):
    """Return a filter corresponding to the current user's
    privileges.

    """
    init_queries = dict([key, _parse_query(dbase, value)]
                        for key, value in viewitems(config.WEB_INIT_QUERIES))
    user = get_user()
    if user in init_queries:
        return init_queries[user]
    if isinstance(user, basestring) and '@' in user:
        realm = user[user.index('@'):]
        if realm in init_queries:
            return init_queries[realm]
    if config.WEB_PUBLIC_SRV:
        return dbase.searchcategory(["Shared", get_anonymized_user()])
    return _parse_query(dbase, config.WEB_DEFAULT_INIT_QUERY) 
开发者ID:cea-sec,项目名称:ivre,代码行数:19,代码来源:utils.py

示例2: display3dgraph

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def display3dgraph(graph, reset_world=True):
        """Send the graph (produced by buildgraph()) to a running
        rtgraph3d instance.

        """
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        bus = dbus.SessionBus()
        control = bus.get_object("org.secdev.rtgraph3d", "/control")
        graph3d = dbus.Interface(control, "org.secdev.rtgraph3d.command")
        if reset_world:
            graph3d.reset_world()
        for node, node_edges in viewitems(graph):
            for destnode in node_edges:
                if destnode == node:
                    continue
                try:
                    graph3d.new_edge(utils.int2ip(node), {},
                                     utils.int2ip(destnode), {})
                except Exception:
                    utils.LOGGER.warning('Exception', exc_info=True)
        return graph3d 
开发者ID:cea-sec,项目名称:ivre,代码行数:23,代码来源:graphroute.py

示例3: normalize_props

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def normalize_props(props, braces=True):
    """Returns a normalized property list/dict so that (roughly):
        - a list gives {k: "{k}"} if braces=True, {k: "k"} otherwise
        - a dict gives {k: v if v is not None else "{%s}" % v} if braces=True,
                       {k: v if v is not Node else "%s" % v} otherwise
    """
    if not isinstance(props, dict):
        props = dict.fromkeys(props)
    # Remove braces if necessary
    if not braces:
        for key, value in viewitems(props):
            if (isinstance(value, basestring) and value.startswith('{') and
                    value.endswith('}')):
                props[key] = value[1:-1]
    form = "{%s}" if braces else "%s"
    props = dict(
        (key, (value if isinstance(value, basestring) else
               (form % key) if value is None else
               str(value))) for key, value in viewitems(props)
    )
    return props 
开发者ID:cea-sec,项目名称:ivre,代码行数:23,代码来源:utils.py

示例4: change_fcrdns_migrate

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def change_fcrdns_migrate(table):
    """Adapt structured output generated by the "fcrdns" Nmap script. The
structured output uses hostnames (hence, data) as keys, which is
undesirable in the databases.

New in SCHEMA_VERSION == 12.

Use this function when migrating existing records.

In previous schema versions, hostnames were used has keys; in keys,
dots are replaced by underscores; this function reverts this change by
replacing underscores by dots. This is OK because underscores are not
allowed in FQDNs.

    """
    return [dict(result, name=name.replace('_', '.'))
            for name, result in viewitems(table)] 
开发者ID:cea-sec,项目名称:ivre,代码行数:19,代码来源:xmlnmap.py

示例5: change_rpcinfo

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def change_rpcinfo(table):
    """Adapt structured output generated by the "rpcinfo" Nmap script. The
structured output uses program numbers (hence, data) as keys, which is
undesirable in the databases. Also, some elements can be converted to
integers.

New in SCHEMA_VERSION == 12.

    """
    result = []
    for program, protores in viewitems(table):
        for proto, data in viewitems(protores):
            data["program"] = int(program)
            data["protocol"] = proto
            try:
                data['port'] = int(data['port'])
            except (KeyError, ValueError):
                pass
            result.append(data)
    return result 
开发者ID:cea-sec,项目名称:ivre,代码行数:22,代码来源:xmlnmap.py

示例6: __migrate_schema_hosts_5_6

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def __migrate_schema_hosts_5_6(doc):
        """Converts a record from version 5 to version 6. Version 6 uses Nmap
        structured data for scripts using the vulns NSE library.

        """
        assert doc["schema_version"] == 5
        doc["schema_version"] = 6
        migrate_scripts = set(script for script, alias
                              in viewitems(xmlnmap.ALIASES_TABLE_ELEMS)
                              if alias == 'vulns')
        for port in doc.get('ports', []):
            for script in port.get('scripts', []):
                if script['id'] in migrate_scripts:
                    table = None
                    if script['id'] in script:
                        table = script.pop(script['id'])
                        script["vulns"] = table
                    elif "vulns" in script:
                        table = script["vulns"]
                    else:
                        continue
                    newtable = xmlnmap.change_vulns(table)
                    if newtable != table:
                        script["vulns"] = newtable 
开发者ID:cea-sec,项目名称:ivre,代码行数:26,代码来源:__init__.py

示例7: __migrate_schema_hosts_7_8

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def __migrate_schema_hosts_7_8(doc):
        """Converts a record from version 7 to version 8. Version 8 fixes the
        structured output for scripts using the vulns NSE library.

        """
        assert doc["schema_version"] == 7
        doc["schema_version"] = 8
        for port in doc.get('ports', []):
            for script in port.get('scripts', []):
                if 'vulns' in script:
                    if any(elt in script['vulns'] for elt in
                           ["ids", "refs", "description", "state", "title"]):
                        script['vulns'] = [script['vulns']]
                    else:
                        script['vulns'] = [dict(tab, id=vulnid)
                                           for vulnid, tab in
                                           viewitems(script['vulns'])] 
开发者ID:cea-sec,项目名称:ivre,代码行数:19,代码来源:__init__.py

示例8: _display_xml_table_elem

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def _display_xml_table_elem(doc, first=False, name=None, out=sys.stdout):
    if first:
        assert name is None
    name = '' if name is None else ' key=%s' % saxutils.quoteattr(name)
    if isinstance(doc, list):
        if not first:
            out.write('<table%s>\n' % name)
        for subdoc in doc:
            _display_xml_table_elem(subdoc, out=out)
        if not first:
            out.write('</table>\n')
    elif isinstance(doc, dict):
        if not first:
            out.write('<table%s>\n' % name)
        for key, subdoc in viewitems(doc):
            _display_xml_table_elem(subdoc, name=key, out=out)
        if not first:
            out.write('</table>\n')
    else:
        out.write('<elem%s>%s</elem>\n' % (name,
                                           saxutils.escape(
                                               str(doc),
                                               entities={'\n': '&#10;'},
                                           ))) 
开发者ID:cea-sec,项目名称:ivre,代码行数:26,代码来源:activecli.py

示例9: OnRefresh

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def OnRefresh(self):
        self.Clear()
        addr_id = {}
        for (loc_key, irblock) in viewitems(self.ircfg.blocks):
            id_irblock = self.AddNode(color_irblock(irblock, self.ircfg))
            addr_id[loc_key] = id_irblock

        for (loc_key, irblock) in viewitems(self.ircfg.blocks):
            if not irblock:
                continue
            all_dst = self.ircfg.dst_trackback(irblock)
            for dst in all_dst:
                if not dst.is_loc():
                    continue
                if not dst.loc_key in self.ircfg.blocks:
                    continue
                node1 = addr_id[loc_key]
                node2 = addr_id[dst.loc_key]
                self.AddEdge(node1, node2)
        return True 
开发者ID:cea-sec,项目名称:miasm,代码行数:22,代码来源:graph_ir.py

示例10: __init__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def __init__(self, parent_head=None, _sex=None, _wsize=None, **kargs):
        self.parent_head = parent_head
        self._size = None
        kargs = dict(kargs)
        # if not sex or size: get the one of the parent
        if _sex == None and _wsize == None:
            if parent_head:
                _sex = parent_head._sex
                _wsize = parent_head._wsize
            else:
                # else default sex & size
                _sex = 0
                _wsize = 32
        # _sex is 0 or 1, sex is '<' or '>'
        self._sex = _sex
        self._wsize = _wsize
        if self._packformat:
            self.sex = self._packformat
        else:
            self.sex = sex_types[_sex]
        for f in self._fields:
            setattr(self, f[0] + self.__class__.field_suffix, None)
        if kargs:
            for k, v in viewitems(kargs):
                self.__dict__[k + self.__class__.field_suffix] = v 
开发者ID:cea-sec,项目名称:miasm,代码行数:27,代码来源:new_cstruct.py

示例11: preload_elf

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def preload_elf(vm, e, runtime_lib, patch_vm_imp=True, loc_db=None):
    # XXX quick hack
    fa = get_import_address_elf(e)
    dyn_funcs = {}
    for (libname, libfunc), ads in viewitems(fa):
        # Quick hack - if a symbol is already known, do not stub it
        if loc_db and loc_db.get_name_location(libfunc) is not None:
            continue
        for ad in ads:
            ad_base_lib = runtime_lib.lib_get_add_base(libname)
            ad_libfunc = runtime_lib.lib_get_add_func(ad_base_lib, libfunc, ad)

            libname_s = canon_libname_libfunc(libname, libfunc)
            dyn_funcs[libname_s] = ad_libfunc
            if patch_vm_imp:
                log.debug('patch 0x%x 0x%x %s', ad, ad_libfunc, libfunc)
                set_endianness = { elf_csts.ELFDATA2MSB: ">",
                                   elf_csts.ELFDATA2LSB: "<",
                                   elf_csts.ELFDATANONE: "" }[e.sex]
                vm.set_mem(ad,
                           struct.pack(set_endianness +
                                       cstruct.size2type[e.size],
                                       ad_libfunc))
    return runtime_lib, dyn_funcs 
开发者ID:cea-sec,项目名称:miasm,代码行数:26,代码来源:elf.py

示例12: preload_pe

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def preload_pe(vm, e, runtime_lib, patch_vm_imp=True):
    fa = get_import_address_pe(e)
    dyn_funcs = {}
    # log.debug('imported funcs: %s' % fa)
    for (libname, libfunc), ads in viewitems(fa):
        for ad in ads:
            libname = force_str(libname)
            ad_base_lib = runtime_lib.lib_get_add_base(libname)
            ad_libfunc = runtime_lib.lib_get_add_func(ad_base_lib, libfunc, ad)

            libname_s = canon_libname_libfunc(libname, libfunc)
            dyn_funcs[libname_s] = ad_libfunc
            if patch_vm_imp:
                vm.set_mem(
                    ad, struct.pack(cstruct.size2type[e._wsize], ad_libfunc))
    return dyn_funcs 
开发者ID:cea-sec,项目名称:miasm,代码行数:18,代码来源:pe.py

示例13: from_ircfg

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def from_ircfg(self, ircfg, append_ret=True):
        # Create basic blocks
        for loc_key, irblock in viewitems(ircfg.blocks):
            self.append_basic_block(loc_key)

        # Add IRBlocks
        for label, irblock in viewitems(ircfg.blocks):
            self.builder.position_at_end(self.get_basic_block_by_loc_key(label))
            self.gen_irblock(irblock)

        # Branch the entry BBL on the IRCFG head
        self.builder.position_at_end(self.entry_bbl)
        heads = ircfg.heads()
        assert len(heads) == 1
        starting_label = list(heads).pop()
        self.builder.branch(self.get_basic_block_by_loc_key(starting_label))

        # Returns with the builder on the exit block
        self.builder.position_at_end(self.exit_bbl)

        if append_ret:
            self.builder.ret_void() 
开发者ID:cea-sec,项目名称:miasm,代码行数:24,代码来源:llvmconvert.py

示例14: remove_callback

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def remove_callback(self, callback):
        """Remove the callback from the list.
        Return the list of empty keys (removed)"""

        to_check = set()
        for key, cb_list in viewitems(self.callbacks):
            try:
                cb_list.remove(callback)
                to_check.add(key)
            except ValueError:
                pass

        empty_keys = []
        for key in to_check:
            if len(self.callbacks[key]) == 0:
                empty_keys.append(key)
                del(self.callbacks[key])

        return empty_keys 
开发者ID:cea-sec,项目名称:miasm,代码行数:21,代码来源:jitload.py

示例15: add_lib_handler

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import viewitems [as 别名]
def add_lib_handler(self, libs, user_globals=None):
        """Add a function to handle libs call with breakpoints
        @libs: libimp instance
        @user_globals: dictionary for defined user function
        """
        if user_globals is None:
            user_globals = {}

        self.libs = libs
        out = {}
        for name, func in viewitems(user_globals):
            out[name] = func
        self.user_globals = out

        for f_addr in libs.fad2cname:
            self.handle_function(f_addr) 
开发者ID:cea-sec,项目名称:miasm,代码行数:18,代码来源:jitload.py


注:本文中的future.utils.viewitems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。