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


Python builtins.basestring方法代码示例

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


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

示例1: validate

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def validate(self, value, session=None):
        # Check that the assigned value is a subclass of the nested class.
        nested_cls = SerializedObject.ImplementationByClass(self.nested)

        # Direct assignment of the correct type.
        if value.__class__ is nested_cls:
            return value

        # Assign a dict to this object, parse from primitive.
        elif isinstance(value, (dict, basestring, int, int, float)):
            return nested_cls.from_primitive(value, session=session)

        # A subclass is assigned.
        elif issubclass(value.__class__, nested_cls):
            return value

        raise ValueError("value is not valid.") 
开发者ID:google,项目名称:rekall,代码行数:19,代码来源:serializer.py

示例2: _set_live

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def _set_live(self, live, _):
        if live is not None and not self.live:
            if isinstance(live, basestring):
                live = [live]

            # Default is to use Memory analysis.
            if len(live) == 0:
                mode = "Memory"
            elif len(live) == 1:
                mode = live[0]
            else:
                raise RuntimeError(
                    "--live parameter should specify only one mode.")

            live_plugin = self.session.plugins.live(mode=mode)
            live_plugin.live()

            # When the session is destroyed, close the live plugin.
            self.session.register_flush_hook(self, live_plugin.close)

        return live 
开发者ID:google,项目名称:rekall,代码行数:23,代码来源:session.py

示例3: GetRenderer

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def GetRenderer(self, output=None):
        """Get a renderer for this session.

        If a renderer is currently active we just reuse it, otherwise we
        instantiate the renderer specified in self.GetParameter("format").
        """
        # Reuse the current renderer.
        if self.renderers and output is None:
            return self.renderers[-1]

        ui_renderer = self.GetParameter("format", "text")
        if isinstance(ui_renderer, basestring):
            ui_renderer_cls = renderer.BaseRenderer.ImplementationByName(
                ui_renderer)
            ui_renderer = ui_renderer_cls(session=self, output=output)

        return ui_renderer 
开发者ID:google,项目名称:rekall,代码行数:19,代码来源:session.py

示例4: testDirectoryIOManager

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def testDirectoryIOManager(self):
        manager = io_manager.DirectoryIOManager(
            self.temp_directory,
            session=self.MakeUserSession())

        # Cant decode from json.
        self.assertEqual(manager.GetData("foo"), None)
        self.assertEqual(manager.GetData("foo", raw=True),
                         b"hello")

        # Test ListFiles().
        self.assertListEqual(sorted(manager.ListFiles()),
                             ["bar", "foo"])

        # Storing a data structure.
        data = dict(a=1)
        manager.StoreData("baz", data)
        self.assertDictEqual(manager.GetData("baz"),
                             data)

        self.assertTrue(
            isinstance(manager.GetData("baz", raw=True), basestring)) 
开发者ID:google,项目名称:rekall,代码行数:24,代码来源:io_manager_test.py

示例5: __init__

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def __init__(self, filename, filesystem=u"API", path_sep=None):
        super(FileSpec, self).__init__()

        if isinstance(filename, FileSpec):
            # Copy the other file spec.
            self.name = filename.name
            self.filesystem = filename.filesystem
            self.path_sep = filename.path_sep

        elif isinstance(filename, basestring):
            self.name = utils.SmartUnicode(filename)
            self.filesystem = filesystem
            self.path_sep = path_sep or self.default_path_sep

        else:
            raise TypeError("Filename must be a string or file spec not %s." % type(
                filename)) 
开发者ID:google,项目名称:rekall,代码行数:19,代码来源:common.py

示例6: render

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def render(self, renderer):
        if isinstance(self.plugin_args.target, basestring):
            self.plugin_args.target = self.profile.Object(
                type_name=self.plugin_args.target,
                offset=self.plugin_args.offset,
                vm=self.plugin_args.address_space)

        item = self.plugin_args.target

        if isinstance(item, obj.Pointer):
            item = item.deref()

        if isinstance(item, obj.Struct):
            return self.render_Struct(renderer, item)

        self.session.plugins.p(self.plugin_args.target).render(renderer) 
开发者ID:google,项目名称:rekall,代码行数:18,代码来源:core.py

示例7: open_key

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def open_key(self, key=""):
        """Opens a key.

        Args:
           key: A string path to the key (separated with / or \\) or a list of
              path components (useful if the keyname contains /).
        """
        if isinstance(key, basestring):
            # / can be part of the key name...
            key = [_f for _f in re.split(r"[\\/]", key) if _f]

        result = self.root
        for component in key:
            result = result.open_subkey(component)

        return result 
开发者ID:google,项目名称:rekall,代码行数:18,代码来源:registry.py

示例8: __getitem__

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def __getitem__(self, item):
        """Get a particular descriptor.

        Descriptors can be requested by name (e.g. VirtualAddressDescriptor) or
        index (e.g. -1).
        """
        if isinstance(item, basestring):
            for descriptor_cls, args, kwargs in self.descriptors:
                if descriptor_cls.__name__ == item:
                    kwargs["session"] = self.session
                    return descriptor_cls(*args, **kwargs)

            return obj.NoneObject("No descriptor found.")
        try:
            cls, args, kwargs = self.descriptors[item]
            kwargs["session"] = self.session
            return cls(*args, **kwargs)
        except KeyError:
            return obj.NoneObject("No descriptor found.") 
开发者ID:google,项目名称:rekall,代码行数:21,代码来源:intel.py

示例9: _cast

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def _cast(value, return_type=None):
    """
    Function takes value and data type to cast.
    Returns result of casting and success status
    """

    if not return_type or value is None:
        return value, True


    try:
        if return_type == bool and isinstance(value, future_basestring):
            if value.lower() == "false":
                return False, True
            if value.lower() == "true":
                return True, True
    except Exception:
        pass

    try:
        return return_type(value), True
    except Exception:
        pass

    return None, False 
开发者ID:aerospike,项目名称:aerospike-admin,代码行数:27,代码来源:util.py

示例10: _get_metrics_groups_with_oid

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def _get_metrics_groups_with_oid(self, oid_name):
        """
        Given an oid_name, returns a set of the names of all metrics groups which use that oid.
        Args:
            oid_name: The name of the oid to query as defined in the oid map.
        Returns:
            A set of the names (as defined in the metrics_groups map) of all metrics groups that reference that oid.
        """
        metrics_groups = set()
        for metrics_group_map in self._config[u"metrics_groups"]:
            for metric_value in list(metrics_group_map[u"metrics"].values()):
                if isinstance(metric_value[u"value"], basestring):
                    if oid_name in metric_value[u"value"]:
                        metrics_groups.add(metrics_group_map[u"group_name"])
            for dimension_value in list(metrics_group_map[u"dimensions"].values()):
                if isinstance(dimension_value[u"value"], basestring):
                    if oid_name in dimension_value[u"value"]:
                        metrics_groups.add(metrics_group_map[u"group_name"])
        return metrics_groups 
开发者ID:yahoo,项目名称:panoptes,代码行数:21,代码来源:plugin_polling_generic_snmp.py

示例11: get_init_flt

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [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

示例12: __init__

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def __init__(self, fdesc, pcap_filter=None):
        """Creates the Argus object.

        fdesc: a file-like object or a filename
        pcap_filter: a PCAP filter to use with racluster
        """
        cmd = ["racluster", "-u", "-n", "-c", ",", "-m"]
        cmd.extend(self.aggregation)
        cmd.append("-s")
        cmd.extend(self.fields)
        cmd.extend(["-r", fdesc if isinstance(fdesc, basestring) else "-"])
        if pcap_filter is not None:
            cmd.extend(["--", pcap_filter])
        super(Argus, self).__init__(
            cmd, {} if isinstance(fdesc, basestring) else {"stdin": fdesc},
        )
        self.fdesc.readline() 
开发者ID:cea-sec,项目名称:ivre,代码行数:19,代码来源:argus.py

示例13: __init__

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def __init__(self, fdesc, pcap_filter=None):
        """Creates the NetFlow object.

        fdesc: a file-like object or a filename
        pcap_filter: a PCAP filter to use with nfdump

        """
        cmd = ["nfdump", "-aq", "-o", self.fmt]
        cmdkargs = {}
        if isinstance(fdesc, basestring):
            with open(fdesc, 'rb') as fde:
                if fde.read(2) not in utils.FileOpener.FILE_OPENERS_MAGIC:
                    cmd.extend(["-r", fdesc])
                else:
                    cmdkargs["stdin"] = utils.open_file(fdesc)
        else:
            cmdkargs["stdin"] = fdesc
        if pcap_filter is not None:
            cmd.append(pcap_filter)
        super(NetFlow, self).__init__(cmd, cmdkargs) 
开发者ID:cea-sec,项目名称:ivre,代码行数:22,代码来源:netflow.py

示例14: all2datetime

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def all2datetime(arg):
    """Return a datetime object from an int (timestamp) or an iso
    formatted string '%Y-%m-%d %H:%M:%S'.

    """
    if isinstance(arg, datetime.datetime):
        return arg
    if isinstance(arg, basestring):
        for fmt in ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f',
                    '%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M:%S.%f']:
            try:
                return datetime.datetime.strptime(arg, fmt)
            except ValueError:
                pass
        raise ValueError('time data %r does not match standard formats' % arg)
    if isinstance(arg, (int_types, float)):
        return datetime.datetime.fromtimestamp(arg)
    raise TypeError("%s is of unknown type." % repr(arg)) 
开发者ID:cea-sec,项目名称:ivre,代码行数:20,代码来源:utils.py

示例15: country_unalias

# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import basestring [as 别名]
def country_unalias(country):
    """Takes either a country code (or an iterator of country codes)
    and returns either a country code or a list of country codes.

    Current aliases are:

      - "UK": alias for "GB".

      - "EU": alias for a list containing the list of the country
        codes of the European Union member states. It also includes
        "EU" itself, because that was a valid "country" code in
        previous Maxmind GeoIP databases.

    """
    if isinstance(country, basestring):
        return COUNTRY_ALIASES.get(country, country)
    if hasattr(country, '__iter__'):
        return functools.reduce(
            lambda x, y: x + (y if isinstance(y, list) else [y]),
            (country_unalias(country_elt) for country_elt in country),
            [],
        )
    return country 
开发者ID:cea-sec,项目名称:ivre,代码行数:25,代码来源:utils.py


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