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


Python builtins.__dict__方法代码示例

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


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

示例1: _analyzeTopFunc

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def _analyzeTopFunc(func, *args, **kwargs):
    tree = _makeAST(func)
    v = _AnalyzeTopFuncVisitor(func, tree, *args, **kwargs)
    v.visit(tree)

    objs = []
    for name, obj in v.fullargdict.items():
        if not isinstance(obj, _Signal):
            objs.append((name, obj))

    # create ports for any signal in the top instance if it was buried in an
    # object passed as in argument

    # now expand the interface objects
    for name, obj in objs:
        if hasattr(obj, '__dict__'):
            # must be an interface object (probably ...?)
            expandinterface(v, name, obj)

    return v 
开发者ID:myhdl,项目名称:myhdl,代码行数:22,代码来源:_analyze.py

示例2: getmembers

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def getmembers(object, predicate=None):
    """Return all members of an object as (name, value) pairs sorted by name.
    Optionally, only return members that satisfy a given predicate."""
    if isclass(object):
        mro = (object,) + getmro(object)
    else:
        mro = ()
    results = []
    for key in dir(object):
        # First try to get the value via __dict__. Some descriptors don't
        # like calling their __get__ (see bug #1785).
        for base in mro:
            if key in base.__dict__:
                value = base.__dict__[key]
                break
        else:
            try:
                value = getattr(object, key)
            except AttributeError:
                continue
        if not predicate or predicate(value):
            results.append((key, value))
    results.sort()
    return results 
开发者ID:war-and-code,项目名称:jawfish,代码行数:26,代码来源:inspect.py

示例3: global_matches

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def global_matches(self, text):
        """Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace that match.

        """
        import keyword
        matches = []
        seen = {"__builtins__"}
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:
                seen.add(word)
                matches.append(word)
        for nspace in [self.namespace, builtins.__dict__]:
            for word, val in nspace.items():
                if word[:n] == text and word not in seen:
                    seen.add(word)
                    matches.append(self._callable_postfix(val, word))
        return matches 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:23,代码来源:rlcompleter.py

示例4: __init__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def __init__(self):
        super().__init__()

        import builtins
        if '__tp_stats__' in builtins.__dict__:
            raise RuntimeError('TPStats object exists, you can not create more than one instance.')

        # 实时数据我们在内存中保留最近10分钟的数据,每5秒收集一次,共 10*60/5 = 120 条记录
        self._sys_stats = list()

        # 网络流量和磁盘IO是递增的数据,因此要记下上一次采集的数据,以便计算间隔时间内的增量
        self._net_recv = 0
        self._net_sent = 0
        self._disk_read = 0
        self._disk_write = 0

        self._counter_stats = {
            'user': 1,
            'host': 0,
            'acc': 0,
            'conn': 0
        } 
开发者ID:tp4a,项目名称:teleport,代码行数:24,代码来源:stats.py

示例5: __init__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def __init__(self):
        if '__teleport_db__' in builtins.__dict__:
            raise RuntimeError('TPDatabase object exists, you can not create more than one instance.')

        self.db_type = self.DB_TYPE_UNKNOWN
        self.sqlite_file = ''
        self.mysql_host = ''
        self.mysql_port = 0
        self.mysql_db = ''
        self.mysql_user = ''
        self.mysql_password = ''

        self.connected = False  # 数据库是否已经连接上了
        self.need_create = False  # 数据尚未存在,需要创建
        self.need_upgrade = False  # 数据库已存在但版本较低,需要升级
        self.current_ver = 0

        self.auto_increment = ''
        self.place_holder = ''

        self._table_prefix = ''
        self._conn_pool = None 
开发者ID:tp4a,项目名称:teleport,代码行数:24,代码来源:db.py

示例6: activate_profiler

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def activate_profiler():
    if sys.version_info[0] == 3:  # PY3
        import builtins
    else:
        import __builtin__ as builtins
    if Options()['misc'].get('profile', False):
        # if profiler is activated, associate line_profiler
        Logger()('Activating line_profiler...')
        try:
            import line_profiler
        except ModuleNotFoundError:
            Logger()('Failed to import line_profiler.', log_level=Logger.ERROR, raise_error=False)
            Logger()('Please install it from https://github.com/rkern/line_profiler', log_level=Logger.ERROR, raise_error=False)
            return
        prof = line_profiler.LineProfiler()
        builtins.__dict__['profile'] = prof
    else:
        # otherwise, create a blank profiler, to disable profiling code
        builtins.__dict__['profile'] = lambda func: func
        prof = None
    return prof 
开发者ID:Cadene,项目名称:bootstrap.pytorch,代码行数:23,代码来源:run.py

示例7: setup_environment

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def setup_environment():
    """Ensures that the environmental variable RAFCON_LIB_PATH is existent
    """
    # The RAFCON_LIB_PATH points to a path with common RAFCON libraries
    # If the env variable is not set, we have to determine it.
    if not os.environ.get('RAFCON_LIB_PATH', None):
        rafcon_library_path = resources.get_data_file_path("rafcon", "libraries")
        if rafcon_library_path:
            os.environ['RAFCON_LIB_PATH'] = rafcon_library_path
        else:
            logger.warning("Could not find root directory of RAFCON libraries. Please specify manually using the "
                           "env var RAFCON_LIB_PATH")

    # Install dummy _ builtin function in case i18.setup_l10n() is not called
    if sys.version_info >= (3,):
        import builtins as builtins23
    else:
        import __builtin__ as builtins23
    if "_" not in builtins23.__dict__:
        builtins23.__dict__["_"] = lambda s: s 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:22,代码来源:start.py

示例8: test_type_relation

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def test_type_relation(self):
        name = 'T'
        base = object
        bases = (base,)
        dict = {'__slots__': ('a', 'b')}
        T = type(name, bases, dict)
        # tp_dict can't be directly tested since .__dict__ returns a proxy
        # and the dict passed is not used directly.
        # We test it indirectly by getting a path through it.
        self.chkpath(T, T.a, "%s.__dict__['a']")
        # The C-struct __slots__ field can't be tested directly
        # This just tests the ordinary attribute
        self.chkpath(T, T.__slots__, "%s.__dict__['__slots__']")
        self.chkrelattr(T, '__mro__', '__base__', '__bases__')
        # tp_cache and tp_subclasses can also not be tested directly

        # Inheritance is tested via test_object_relation() 
开发者ID:zhuyifei1999,项目名称:guppy3,代码行数:19,代码来源:test_Path.py

示例9: complete

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def complete(self, text, state):
        """Return the next possible completion for 'text'.

        This is called successively with state == 0, 1, 2, ... until it
        returns None.  The completion should begin with 'text'.

        """
        if self.use_main_ns:
            self.namespace = __main__.__dict__

        if not text.strip():
            if state == 0:
                return '\t'
            else:
                return None

        if state == 0:
            if "." in text:
                self.matches = self.attr_matches(text)
            else:
                self.matches = self.global_matches(text)
        try:
            return self.matches[state]
        except IndexError:
            return None 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:rlcompleter.py

示例10: global_matches

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def global_matches(self, text):
        """Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace that match.

        """
        import keyword
        matches = []
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:
                matches.append(word)
        for nspace in [builtins.__dict__, self.namespace]:
            for word, val in nspace.items():
                if word[:n] == text and word != "__builtins__":
                    matches.append(self._callable_postfix(val, word))
        return matches 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:rlcompleter.py

示例11: isabstract

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def isabstract(object):
    """Return true if the object is an abstract base class (ABC)."""
    if not isinstance(object, type):
        return False
    if object.__flags__ & TPFLAGS_IS_ABSTRACT:
        return True
    if not issubclass(type(object), abc.ABCMeta):
        return False
    if hasattr(object, '__abstractmethods__'):
        # It looks like ABCMeta.__new__ has finished running;
        # TPFLAGS_IS_ABSTRACT should have been accurate.
        return False
    # It looks like ABCMeta.__new__ has not finished running yet; we're
    # probably in __init_subclass__. We'll look for abstractmethods manually.
    for name, value in object.__dict__.items():
        if getattr(value, "__isabstractmethod__", False):
            return True
    for base in object.__bases__:
        for name in getattr(base, "__abstractmethods__", ()):
            value = getattr(object, name, None)
            if getattr(value, "__isabstractmethod__", False):
                return True
    return False 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:25,代码来源:inspect.py

示例12: expandinterface

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def expandinterface(v, name, obj):
    for attr, attrobj in vars(obj).items():
        if isinstance(attrobj, _Signal):
            signame = attrobj._name
            if not signame:
                signame = name + '_' + attr
                attrobj._name = signame
            v.argdict[signame] = attrobj
            v.argnames.append(signame)
        elif isinstance(attrobj, myhdl.EnumType):
            pass
        elif hasattr(attrobj, '__dict__'):
            # can assume is yet another interface ...
            expandinterface(v, name + '_' + attr, attrobj) 
开发者ID:myhdl,项目名称:myhdl,代码行数:16,代码来源:_analyze.py

示例13: _static_getmro

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def _static_getmro(klass):
    return type.__dict__['__mro__'].__get__(klass) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:4,代码来源:inspect.py

示例14: _check_instance

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def _check_instance(obj, attr):
    instance_dict = {}
    try:
        instance_dict = object.__getattribute__(obj, "__dict__")
    except AttributeError:
        pass
    return dict.get(instance_dict, attr, _sentinel) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:9,代码来源:inspect.py

示例15: _check_class

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import __dict__ [as 别名]
def _check_class(klass, attr):
    for entry in _static_getmro(klass):
        if _shadowed_dict(type(entry)) is _sentinel:
            try:
                return entry.__dict__[attr]
            except KeyError:
                pass
    return _sentinel 
开发者ID:war-and-code,项目名称:jawfish,代码行数:10,代码来源:inspect.py


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