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


Python imp.C_EXTENSION属性代码示例

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


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

示例1: find_module

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def find_module(self, fullname, path=None):
    if fullname in _WHITE_LIST_C_MODULES:
      return None
    if any(regex.match(fullname) for regex in self._enabled_regexes):
      return None
    _, _, submodule_name = fullname.rpartition('.')
    try:
      result = imp.find_module(submodule_name, path)
    except ImportError:
      return None
    f, _, description = result
    _, _, file_type = description
    if isinstance(f, file):
      f.close()
    if file_type == imp.C_EXTENSION:
      return self
    return None 
开发者ID:elsigh,项目名称:browserscope,代码行数:19,代码来源:sandbox.py

示例2: load_module

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def load_module(self, name, stuff):
        file, filename, info = stuff
        (suff, mode, type) = info
        try:
            if type == BUILTIN_MODULE:
                return self.hooks.init_builtin(name)
            if type == FROZEN_MODULE:
                return self.hooks.init_frozen(name)
            if type == C_EXTENSION:
                m = self.hooks.load_dynamic(name, filename, file)
            elif type == PY_SOURCE:
                m = self.hooks.load_source(name, filename, file)
            elif type == PY_COMPILED:
                m = self.hooks.load_compiled(name, filename, file)
            elif type == PKG_DIRECTORY:
                m = self.hooks.load_package(name, filename, file)
            else:
                raise ImportError, "Unrecognized module type (%r) for %s" % \
                      (type, name)
        finally:
            if file: file.close()
        m.__file__ = filename
        return m 
开发者ID:glmcdona,项目名称:meddle,代码行数:25,代码来源:ihooks.py

示例3: test_c_module_accessible

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def test_c_module_accessible(self):
    imp.find_module('bar', ['foo']).AndReturn((None, 'foo/bar.so',
                                               (None, None, imp.C_EXTENSION)))
    stubs.FakeFile.is_file_accessible('foo/bar.so').AndReturn(True)
    self.mox.ReplayAll()
    self.assertIsNone(self.hook.find_module('foo.bar', ['foo'])) 
开发者ID:elsigh,项目名称:browserscope,代码行数:8,代码来源:sandbox_test.py

示例4: test_c_module_not_accessible

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def test_c_module_not_accessible(self):
    imp.find_module('bar', ['foo']).AndReturn((None, 'foo/bar.so',
                                               (None, None, imp.C_EXTENSION)))
    stubs.FakeFile.is_file_accessible('foo/bar.so').AndReturn(False)
    self.mox.ReplayAll()
    self.assertEqual(self.hook, self.hook.find_module('foo.bar', ['foo'])) 
开发者ID:elsigh,项目名称:browserscope,代码行数:8,代码来源:sandbox_test.py

示例5: get_abi3_suffix

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def get_abi3_suffix():
    """Return the file extension for an abi3-compliant Extension()"""
    for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION):
        if '.abi3' in suffix:  # Unix
            return suffix
        elif suffix == '.pyd':  # Windows
            return suffix 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:9,代码来源:build_ext.py

示例6: _reopen

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def _reopen(self):
        if self.file and self.file.closed:
            mod_type = self.etc[2]
            if mod_type==imp.PY_SOURCE:
                self.file = open(self.filename, 'rU')
            elif mod_type in (imp.PY_COMPILED, imp.C_EXTENSION):
                self.file = open(self.filename, 'rb') 
开发者ID:glmcdona,项目名称:meddle,代码行数:9,代码来源:pkgutil.py

示例7: get_filename

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def get_filename(self, fullname=None):
        fullname = self._fix_name(fullname)
        mod_type = self.etc[2]
        if self.etc[2]==imp.PKG_DIRECTORY:
            return self._get_delegate().get_filename()
        elif self.etc[2] in (imp.PY_SOURCE, imp.PY_COMPILED, imp.C_EXTENSION):
            return self.filename
        return None 
开发者ID:glmcdona,项目名称:meddle,代码行数:10,代码来源:pkgutil.py

示例8: iter_importers

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def iter_importers(fullname=""):
    """Yield PEP 302 importers for the given module name

    If fullname contains a '.', the importers will be for the package
    containing fullname, otherwise they will be importers for sys.meta_path,
    sys.path, and Python's "classic" import machinery, in that order.  If
    the named module is in a package, that package is imported as a side
    effect of invoking this function.

    Non PEP 302 mechanisms (e.g. the Windows registry) used by the
    standard import machinery to find files in alternative locations
    are partially supported, but are searched AFTER sys.path. Normally,
    these locations are searched BEFORE sys.path, preventing sys.path
    entries from shadowing them.

    For this to cause a visible difference in behaviour, there must
    be a module or package name that is accessible via both sys.path
    and one of the non PEP 302 file system mechanisms. In this case,
    the emulation will find the former version, while the builtin
    import mechanism will find the latter.

    Items of the following types can be affected by this discrepancy:
        imp.C_EXTENSION, imp.PY_SOURCE, imp.PY_COMPILED, imp.PKG_DIRECTORY
    """
    if fullname.startswith('.'):
        raise ImportError("Relative module names not supported")
    if '.' in fullname:
        # Get the containing package's __path__
        pkg = '.'.join(fullname.split('.')[:-1])
        if pkg not in sys.modules:
            __import__(pkg)
        path = getattr(sys.modules[pkg], '__path__', None) or []
    else:
        for importer in sys.meta_path:
            yield importer
        path = sys.path
    for item in path:
        yield get_importer(item)
    if '.' not in fullname:
        yield ImpImporter() 
开发者ID:glmcdona,项目名称:meddle,代码行数:42,代码来源:pkgutil.py

示例9: test_flags

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def test_flags(self):
        self.assertEqual(imp.SEARCH_ERROR,0)
        self.assertEqual(imp.PY_SOURCE,1)
        self.assertEqual(imp.PY_COMPILED,2)
        self.assertEqual(imp.C_EXTENSION,3)
        self.assertEqual(imp.PY_RESOURCE,4)
        self.assertEqual(imp.PKG_DIRECTORY,5)
        self.assertEqual(imp.C_BUILTIN,6)
        self.assertEqual(imp.PY_FROZEN,7)
        self.assertEqual(imp.PY_CODERESOURCE,8) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_imp.py

示例10: get_abi3_suffix

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def get_abi3_suffix():
    """Return the file extension for an abi3-compliant Extension()"""
    for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION):
        if '.abi3' in suffix:   # Unix
            return suffix
        elif suffix == '.pyd':  # Windows
            return suffix 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:9,代码来源:build_ext.py

示例11: _extension_suffixes

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def _extension_suffixes():
        return [suffix for suffix, _, type in imp.get_suffixes()
                if type == imp.C_EXTENSION] 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:5,代码来源:verifier.py

示例12: _get_so_suffixes

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_EXTENSION [as 别名]
def _get_so_suffixes():
    suffixes = _extension_suffixes()
    if not suffixes:
        # bah, no C_EXTENSION available.  Occurs on pypy without cpyext
        if sys.platform == 'win32':
            suffixes = [".pyd"]
        else:
            suffixes = [".so"]

    return suffixes 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:12,代码来源:verifier.py


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