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


Python sys.builtin_module_names方法代码示例

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


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

示例1: storeFrameLocals

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def storeFrameLocals(self, frmnr=0):
        """Stores the locals into the frame.

        Thus an access to frame.f_locals returns the last data
        """
        cf = self.currentFrame
        while cf is not None and frmnr > 0:
            cf = cf.f_back
            frmnr -= 1

        try:
            if '__pypy__' in sys.builtin_module_names:
                import __pypy__
                __pypy__.locals_to_fast(cf)
                return
        except Exception:
            pass

        ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(cf),
                                              ctypes.c_int(0)) 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:22,代码来源:base_cdm_dbg.py

示例2: find_module

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def find_module(self, name, path, parent=None):
        if parent is not None:
            # assert path is not None
            fullname = parent.__name__+'.'+name
        else:
            fullname = name
        if fullname in self.excludes:
            self.msgout(3, "find_module -> Excluded", fullname)
            raise ImportError, name

        if path is None:
            if name in sys.builtin_module_names:
                return (None, None, ("", "", imp.C_BUILTIN))

            path = self.path
        return imp.find_module(name, path) 
开发者ID:glmcdona,项目名称:meddle,代码行数:18,代码来源:modulefinder.py

示例3: test_module_exceptions

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def test_module_exceptions(self):
        """verify exceptions in modules are like user defined exception objects, not built-in types."""
        
        # these modules have normal types...
        normal_types = ['sys', 'clr', 'exceptions', '__builtin__', '_winreg', 'mmap', 'nt', 'posix']       
        builtins = [x for x in sys.builtin_module_names if x not in normal_types ]
        for module in builtins:
            mod = __import__(module)
            
            for attrName in dir(mod):
                val = getattr(mod, attrName)
                if isinstance(val, type) and issubclass(val, Exception):
                    if "BlockingIOError" not in repr(val): 
                        self.assertTrue(repr(val).startswith("<class "))
                        val.x = 2
                        self.assertEqual(val.x, 2)
                    else:
                        self.assertTrue(repr(val).startswith("<type ")) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_exceptions.py

示例4: _check_stdlib_path

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def _check_stdlib_path(module, mod_name, stdlib_paths):
    if (
        not module
        or mod_name in sys.builtin_module_names
        or not hasattr(module, "__file__")
    ):
        # an import sentinel, built-in module or not a real module, really
        return mod_name
    # Test the path
    fname = module.__file__
    if fname.endswith(("__init__.py", "__init__.pyc", "__init__.pyo")):
        fname = Path(fname).parent

    if "site-packages" in str(fname).lower():
        return None

    # step up the module path
    while Path(fname) != Path(fname).parent:
        if str(fname).lower() in stdlib_paths:
            # stdlib path, skip
            return mod_name
        fname = Path(fname).parent
    return None 
开发者ID:microsoft,项目名称:msticpy,代码行数:25,代码来源:import_analyzer.py

示例5: _locate_engine_class

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def _locate_engine_class(ffi, force_generic_engine):
    if _FORCE_GENERIC_ENGINE:
        force_generic_engine = True
    if not force_generic_engine:
        if '__pypy__' in sys.builtin_module_names:
            force_generic_engine = True
        else:
            try:
                import _cffi_backend
            except ImportError:
                _cffi_backend = '?'
            if ffi._backend is not _cffi_backend:
                force_generic_engine = True
    if force_generic_engine:
        from . import vengine_gen
        return vengine_gen.VGenericEngine
    else:
        from . import vengine_cpy
        return vengine_cpy.VCPythonEngine

# ____________________________________________________________ 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:23,代码来源:verifier.py

示例6: find_module

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def find_module(self, name, path, parent=None):
        if parent is not None:
            # assert path is not None
            fullname = parent.__name__ + '.' + name
        else:
            fullname = name
        if fullname in self.excludes:
            self.msgout(3, "find_module -> Excluded", fullname)
            raise ImportError(name)

        if path is None:
            if name in sys.builtin_module_names:
                return (None, None, ("", "", imp.C_BUILTIN))

            path = self.path
        return imp.find_module(name, path) 
开发者ID:thebjorn,项目名称:pydeps,代码行数:18,代码来源:mf27.py

示例7: loadModule

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def loadModule(self, modulename, module):
        if modulename in self.modulesVisited:
            return
        self.modulesVisited.add(modulename)

        #ignore all modules that are not part of the base python installation.
        #this is a crude way of deciding which modules are going to be available
        #on both the host and the server.
        if modulename not in sys.builtin_module_names and (
                not hasattr(module, '__file__') or not os.path.abspath(module.__file__).startswith(sys.prefix)
                ):
            return

        if module is not None:
            d = dict(module.__dict__)
            for leafItemName, leafItemValue in d.iteritems():
                self.module_objects_by_name["modules", modulename, leafItemName] = leafItemValue
                self.modules_and_names_by_object[id(leafItemValue)] = ("modules", modulename, leafItemName)
            self.modules_and_names_by_object[id(module)] = ("modules", modulename)
            self.module_objects_by_name["modules", modulename] = module 
开发者ID:ufora,项目名称:ufora,代码行数:22,代码来源:ModuleLevelObjectIndex.py

示例8: _get_module_names

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def _get_module_names(self, search_path=None):
        """
        Get the names of all modules in the search_path. This means file names
        and not names defined in the files.
        """

        names = []
        # add builtin module names
        if search_path is None:
            names += [self._generate_name(name) for name in sys.builtin_module_names]

        if search_path is None:
            search_path = self._importer.sys_path_with_modifications()
        for module_loader, name, is_pkg in pkgutil.iter_modules(search_path):
            names.append(self._generate_name(name))
        return names 
开发者ID:weijer,项目名称:NukeToolSet,代码行数:18,代码来源:imports.py

示例9: describe

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def describe(thing):
    """Produce a short description of the given thing."""
    if inspect.ismodule(thing):
        if thing.__name__ in sys.builtin_module_names:
            return 'built-in module ' + thing.__name__
        if hasattr(thing, '__path__'):
            return 'package ' + thing.__name__
        else:
            return 'module ' + thing.__name__
    if inspect.isbuiltin(thing):
        return 'built-in function ' + thing.__name__
    if inspect.isgetsetdescriptor(thing):
        return 'getset descriptor %s.%s.%s' % (
            thing.__objclass__.__module__, thing.__objclass__.__name__,
            thing.__name__)
    if inspect.ismemberdescriptor(thing):
        return 'member descriptor %s.%s.%s' % (
            thing.__objclass__.__module__, thing.__objclass__.__name__,
            thing.__name__)
    if inspect.isclass(thing):
        return 'class ' + thing.__name__
    if inspect.isfunction(thing):
        return 'function ' + thing.__name__
    if inspect.ismethod(thing):
        return 'method ' + thing.__name__
    return type(thing).__name__ 
开发者ID:war-and-code,项目名称:jawfish,代码行数:28,代码来源:pydoc.py

示例10: is_py2_stdlib_module

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def is_py2_stdlib_module(m):
    """
    Tries to infer whether the module m is from the Python 2 standard library.
    This may not be reliable on all systems.
    """
    if PY3:
        return False
    if not 'stdlib_path' in is_py2_stdlib_module.__dict__:
        stdlib_files = [contextlib.__file__, os.__file__, copy.__file__]
        stdlib_paths = [os.path.split(f)[0] for f in stdlib_files]
        if not len(set(stdlib_paths)) == 1:
            # This seems to happen on travis-ci.org. Very strange. We'll try to
            # ignore it.
            flog.warn('Multiple locations found for the Python standard '
                         'library: %s' % stdlib_paths)
        # Choose the first one arbitrarily
        is_py2_stdlib_module.stdlib_path = stdlib_paths[0]

    if m.__name__ in sys.builtin_module_names:
        return True

    if hasattr(m, '__file__'):
        modpath = os.path.split(m.__file__)
        if (modpath[0].startswith(is_py2_stdlib_module.stdlib_path) and
            'site-packages' not in modpath[0]):
            return True

    return False 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:30,代码来源:__init__.py

示例11: find_module

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def find_module(self, fullname, unused_path=None):
    if (fullname in sys.builtin_module_names and
        fullname not in _WHITE_LIST_C_MODULES):
      return self
    return None 
开发者ID:elsigh,项目名称:browserscope,代码行数:7,代码来源:sandbox.py

示例12: StubModuleExists

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def StubModuleExists(self, name):
    """Check if the named module has a stub replacement."""
    if name in sys.builtin_module_names:
      name = 'py_%s' % name
    if self._config and self._config.runtime == 'python27':
      if name in dist27.MODULE_OVERRIDES:
        return True
    else:
      if name in dist.__all__:
        return True
    return False 
开发者ID:elsigh,项目名称:browserscope,代码行数:13,代码来源:dev_appserver_import_hook.py

示例13: ImportStubModule

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def ImportStubModule(self, name):
    """Import the stub module replacement for the specified module."""
    if name in sys.builtin_module_names:
      name = 'py_%s' % name


    providing_dist = dist
    if self._config and self._config.runtime == 'python27':


      if name in dist27.__all__:
        providing_dist = dist27
    fullname = '%s.%s' % (providing_dist.__name__, name)
    __import__(fullname, {}, {})
    return sys.modules[fullname] 
开发者ID:elsigh,项目名称:browserscope,代码行数:17,代码来源:dev_appserver_import_hook.py

示例14: updateThreadList

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def updateThreadList(self):
        """Updates the list of running threads"""
        frames = sys._current_frames()
        for threadId, frame in frames.items():
            # skip our own timer thread
            if frame.f_code.co_name == '__eventPollTimer':
                continue

            # Unknown thread
            if threadId not in self.threads:
                newThread = DebugBase(self)
                name = 'Thread-{0}'.format(self.threadNumber)
                self.threadNumber += 1

                newThread.id = threadId
                newThread.name = name
                self.threads[threadId] = newThread

            # adjust current frame
            if "__pypy__" not in sys.builtin_module_names:
                # Don't update with None
                currentFrame = self.getExecutedFrame(frame)
                if (currentFrame is not None and
                        self.threads[threadId].isBroken is False):
                    self.threads[threadId].currentFrame = currentFrame

        # Clean up obsolet because terminated threads
        self.threads = {id_: thrd for id_, thrd in self.threads.items()
                        if id_ in frames}

    # find_module(self, fullname, path=None) 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:33,代码来源:threadextension_cdm_dbg.py

示例15: collect_stdlib_distributions

# 需要导入模块: import sys [as 别名]
# 或者: from sys import builtin_module_names [as 别名]
def collect_stdlib_distributions():
    """Yield a conventional spec and the names of all top_level standard library modules."""
    distribution_spec = 'Python==%d.%d.%d' % sys.version_info[:3]
    stdlib_path = sysconfig.get_python_lib(standard_lib=True)
    distribution_top_level = [name for _, name, _ in pkgutil.iter_modules(path=[stdlib_path])]
    distribution_top_level += list(sys.builtin_module_names)
    yield distribution_spec, distribution_top_level 
开发者ID:nodev-io,项目名称:pytest-nodev,代码行数:9,代码来源:collect.py


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