我正在将一些非常古老的代码移植到python3中。 我遇到了一个函数,它试图使用ihooks加载一些其他模块。你知道吗
感兴趣的代码是:
def _getCOMModuleForLocation(self, componentFile):
fqn = componentFile.path
mod = self.com_modules.get(fqn)
if mod is not None:
return mod
import ihooks, sys
base_name = os.path.splitext(os.path.basename(fqn))[0]
loader = ihooks.ModuleLoader()
module_name_in_sys = "component:%s" % (base_name,)
stuff = loader.find_module(base_name, [componentFile.parent.path])
assert stuff is not None, "Couldnt find the module '%s'" % (base_name,)
py_mod = loader.load_module( module_name_in_sys, stuff )
# Make and remember the COM module.
comps = FindCOMComponents(py_mod)
mod = self.moduleFactory(comps)
self.com_modules[fqn] = mod
return mod
你能帮我使这段代码与python3兼容,同时保持与2.6和2.7的向后兼容性吗?你知道吗
更新
看起来我找到了如何在3.1+下工作:importlib
但3.0的问题仍然存在。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐