當前位置: 首頁>>代碼示例>>Python>>正文


Python imp.load_dynamic方法代碼示例

本文整理匯總了Python中imp.load_dynamic方法的典型用法代碼示例。如果您正苦於以下問題:Python imp.load_dynamic方法的具體用法?Python imp.load_dynamic怎麽用?Python imp.load_dynamic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在imp的用法示例。


在下文中一共展示了imp.load_dynamic方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_module

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [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

示例2: _verify

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def _verify(ffi, module_name, preamble, *args, **kwds):
    # FOR TESTS ONLY
    from testing.udir import udir
    import imp
    assert module_name not in sys.modules, "module name conflict: %r" % (
        module_name,)
    kwds.setdefault('tmpdir', str(udir))
    outputfilename = recompile(ffi, module_name, preamble, *args, **kwds)
    module = imp.load_dynamic(module_name, outputfilename)
    #
    # hack hack hack: copy all *bound methods* from module.ffi back to the
    # ffi instance.  Then calls like ffi.new() will invoke module.ffi.new().
    for name in dir(module.ffi):
        if not name.startswith('_'):
            attr = getattr(module.ffi, name)
            if attr is not getattr(ffi, name, object()):
                setattr(ffi, name, attr)
    def typeof_disabled(*args, **kwds):
        raise NotImplementedError
    ffi._typeof = typeof_disabled
    for name in dir(ffi):
        if not name.startswith('_') and not hasattr(module.ffi, name):
            setattr(ffi, name, NotImplemented)
    return module.lib 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:26,代碼來源:recompiler.py

示例3: _verify

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def _verify(ffi, module_name, preamble, *args, **kwds):
    # FOR TESTS ONLY
    from testing.udir import udir
    import imp
    assert module_name not in sys.modules, "module name conflict: %r" % (
        module_name,)
    kwds.setdefault('tmpdir', str(udir))
    outputfilename = recompile(ffi, module_name, preamble, *args, **kwds)
    module = imp.load_dynamic(module_name, outputfilename)
    #
    # hack hack hack: copy all *bound methods* from module.ffi back to the
    # ffi instance.  Then calls like ffi.new() will invoke module.ffi.new().
    for name in dir(module.ffi):
        if not name.startswith('_'):
            attr = getattr(module.ffi, name)
            if attr is not getattr(ffi, name, object()):
                setattr(ffi, name, attr)
    def typeof_disabled(*args, **kwds):
        raise NotImplementedError
    ffi._typeof = typeof_disabled
    return module.lib 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:23,代碼來源:recompiler.py

示例4: load_module

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def load_module(self, fullname):
        if fullname in sys.modules:
            result = sys.modules[fullname]
        else:
            if fullname not in self.libs:
                raise ImportError('unable to find extension for %s' % fullname)
            result = imp.load_dynamic(fullname, self.libs[fullname])
            result.__loader__ = self
            parts = fullname.rsplit('.', 1)
            if len(parts) > 1:
                result.__package__ = parts[0]
        return result 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:wheel.py

示例5: write_stub

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def write_stub(resource, pyfile):
    _stub_template = textwrap.dedent("""
        def __bootstrap__():
            global __bootstrap__, __loader__, __file__
            import sys, pkg_resources, imp
            __file__ = pkg_resources.resource_filename(__name__, %r)
            __loader__ = None; del __bootstrap__, __loader__
            imp.load_dynamic(__name__,__file__)
        __bootstrap__()
        """).lstrip()
    with open(pyfile, 'w') as f:
        f.write(_stub_template % resource) 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:bdist_egg.py

示例6: __bootstrap__

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __bootstrap__():
  global __bootstrap__, __loader__, __file__
  __file__ = pkg_resources.resource_filename(__name__, 'cython_nms.so')
  __loader__ = None
  del __bootstrap__, __loader__
  imp.load_dynamic(__name__, __file__) 
開發者ID:CharlesShang,項目名稱:FastMaskRCNN,代碼行數:8,代碼來源:cython_nms.py

示例7: __bootstrap__

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __bootstrap__():
  global __bootstrap__, __loader__, __file__
  __file__ = pkg_resources.resource_filename(__name__, 'cython_bbox.so')
  __loader__ = None
  del __bootstrap__, __loader__
  imp.load_dynamic(__name__, __file__) 
開發者ID:CharlesShang,項目名稱:FastMaskRCNN,代碼行數:8,代碼來源:cython_bbox.py

示例8: __bootstrap__

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __bootstrap__():
  global __bootstrap__, __loader__, __file__
  __file__ = pkg_resources.resource_filename(__name__, 'cython_bbox_transform.so')
  __loader__ = None
  del __bootstrap__, __loader__
  imp.load_dynamic(__name__, __file__) 
開發者ID:CharlesShang,項目名稱:FastMaskRCNN,代碼行數:8,代碼來源:cython_bbox_transform.py

示例9: __bootstrap__

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __bootstrap__():
  global __bootstrap__, __loader__, __file__
  __file__ = pkg_resources.resource_filename(__name__, 'cython_anchor.so')
  __loader__ = None
  del __bootstrap__, __loader__
  imp.load_dynamic(__name__, __file__) 
開發者ID:CharlesShang,項目名稱:FastMaskRCNN,代碼行數:8,代碼來源:cython_anchor.py

示例10: load_dynamic

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def load_dynamic(self, name, filename, file):
        return self.rexec.load_dynamic(name, filename, file) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:4,代碼來源:rexec.py

示例11: load_dynamic

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def load_dynamic(self, name, filename, file=None):
        return imp.load_dynamic(name, filename, file) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:4,代碼來源:ihooks.py

示例12: __load

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __load():
    import imp, os, sys
    try:
        dirname = os.path.dirname(__loader__.archive)
    except NameError:
        dirname = sys.prefix
    path = os.path.join(dirname, '_ssl.pyd')
    #print "py2exe extension module", __name__, "->", path
    mod = imp.load_dynamic(__name__, path)
##    mod.frozen = 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:_ssl.py

示例13: __load

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __load():
    import imp, os, sys
    try:
        dirname = os.path.dirname(__loader__.archive)
    except NameError:
        dirname = sys.prefix
    path = os.path.join(dirname, 'win32event.pyd')
    #print "py2exe extension module", __name__, "->", path
    mod = imp.load_dynamic(__name__, path)
##    mod.frozen = 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:win32event.py

示例14: __load

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __load():
    import imp, os, sys
    try:
        dirname = os.path.dirname(__loader__.archive)
    except NameError:
        dirname = sys.prefix
    path = os.path.join(dirname, 'win32security.pyd')
    #print "py2exe extension module", __name__, "->", path
    mod = imp.load_dynamic(__name__, path)
##    mod.frozen = 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:win32security.py

示例15: __load

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import load_dynamic [as 別名]
def __load():
    import imp, os, sys
    try:
        dirname = os.path.dirname(__loader__.archive)
    except NameError:
        dirname = sys.prefix
    path = os.path.join(dirname, 'unicodedata.pyd')
    #print "py2exe extension module", __name__, "->", path
    mod = imp.load_dynamic(__name__, path)
##    mod.frozen = 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:unicodedata.py


注:本文中的imp.load_dynamic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。