Created
April 14, 2014 02:37
-
-
Save Kentzo/10611924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment