本文整理匯總了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
示例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
示例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
示例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
示例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)
示例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__)
示例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__)
示例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__)
示例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__)
示例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)
示例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)
示例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
示例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
示例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
示例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