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


Python imp.C_BUILTIN属性代码示例

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


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

示例1: find_module

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

示例2: find_module

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

示例3: find_module

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_BUILTIN [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:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:modulefinder.py

示例4: test_c_builtin

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

示例5: test_flags

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

示例6: get_handler

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_BUILTIN [as 别名]
def get_handler():
    if "IOPIPE_HANDLER" not in os.environ or not os.environ["IOPIPE_HANDLER"]:
        raise ValueError("No value specified in IOPIPE_HANDLER environment variable")

    try:
        module_path, handler_name = os.environ["IOPIPE_HANDLER"].rsplit(".", 1)
    except ValueError:
        raise ValueError(
            "Improperly formated handler value: %s" % os.environ["IOPIPE_HANDLER"]
        )

    module_path = module_path.replace("/", ".")
    file_handle, pathname, desc = None, None, None

    try:
        for segment in module_path.split("."):
            if pathname is not None:
                pathname = [pathname]

            file_handle, pathname, desc = imp.find_module(segment, pathname)

        if file_handle is None:
            module_type = desc[2]
            if module_type == imp.C_BUILTIN:
                raise ImportError(
                    "Cannot use built-in module %s as a handler module" % module_path
                )

        module = imp.load_module(module_path, file_handle, pathname, desc)
    except Exception as e:
        raise ImportError("Failed to import module: %s" % module_path)
    finally:
        if file_handle is not None:
            file_handle.close()

    try:
        handler = getattr(module, handler_name)
    except AttributeError as e:
        raise AttributeError("No handler %s in module %s" % (handler_name, module_path))

    return handler 
开发者ID:iopipe,项目名称:iopipe-python,代码行数:43,代码来源:handler.py

示例7: _file_from_modpath

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_BUILTIN [as 别名]
def _file_from_modpath(modpath, path=None, context=None):
    """given a mod path (ie splited module / package name), return the
    corresponding file

    this function is used internally, see `file_from_modpath`'s
    documentation for more information
    """
    assert len(modpath) > 0
    if context is not None:
        try:
            mtype, mp_filename = _module_file(modpath, [context])
        except ImportError:
            mtype, mp_filename = _module_file(modpath, path)
    else:
        mtype, mp_filename = _module_file(modpath, path)
    if mtype == PY_COMPILED:
        try:
            return get_source_file(mp_filename)
        except NoSourceFile:
            return mp_filename
    elif mtype == C_BUILTIN:
        # integrated builtin module
        return None
    elif mtype == PKG_DIRECTORY:
        mp_filename = _has_init(mp_filename)
    return mp_filename 
开发者ID:jlachowski,项目名称:clonedigger,代码行数:28,代码来源:modutils.py

示例8: find_module

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_BUILTIN [as 别名]
def find_module(self, fullname, path=None):
    if (fullname in _WHITE_LIST_C_MODULES or
        any(regex.match(fullname) for regex in self._enabled_regexes)):
      return None
    if self._module_type(fullname, path) in [imp.C_EXTENSION, imp.C_BUILTIN]:
      return self
    return None 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:9,代码来源:sandbox.py

示例9: _get_handler

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_BUILTIN [as 别名]
def _get_handler(handler):
    try:
        (modname, fname) = handler.rsplit('.', 1)
    except ValueError as e:
        fault = FaultException("Bad handler '{}'".format(handler), str(e), None)
        request_handler = make_fault_handler(fault)
        return request_handler

    file_handle, pathname, desc = None, None, None
    try:
        # Recursively loading handler in nested directories
        for segment in modname.split('.'):
            if pathname is not None:
                pathname = [pathname]
            file_handle, pathname, desc = imp.find_module(segment, pathname)
        if file_handle is None:
            module_type = desc[2]
            if module_type == imp.C_BUILTIN:
                fault = FaultException("Cannot use built-in module {} as a handler module".format(modname), None, None)
                request_handler = make_fault_handler(fault)
                return request_handler
        m = imp.load_module(modname, file_handle, pathname, desc)
    except ImportError as e:
        fault = FaultException("Unable to import module '{}'".format(modname), str(e), None)
        request_handler = make_fault_handler(fault)
        return request_handler
    except SyntaxError as e:
        trace = "File \"%s\" Line %s\n\t%s" % (e.filename, e.lineno, e.text)
        fault = FaultException("Syntax error in module '{}'".format(modname), str(e), trace)
        request_handler = make_fault_handler(fault)
        return request_handler
    finally:
        if file_handle is not None:
            file_handle.close()

    try:
        request_handler = getattr(m, fname)
    except AttributeError as e:
        fault = FaultException("Handler '{}' missing on module '{}'".format(fname, modname), str(e), None)
        request_handler = make_fault_handler(fault)
    return request_handler 
开发者ID:triggermesh,项目名称:knative-lambda-runtime,代码行数:43,代码来源:bootstrap.py

示例10: getmod

# 需要导入模块: import imp [as 别名]
# 或者: from imp import C_BUILTIN [as 别名]
def getmod(self, nm, isbuiltin=imp.is_builtin):
        if isbuiltin(nm):
            mod = imp.load_module(nm, None, nm, ('', '', imp.C_BUILTIN))
            return mod
        return None 
开发者ID:binhex,项目名称:moviegrabber,代码行数:7,代码来源:ImportManager.py


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