Skip to content

Instantly share code, notes, and snippets.

@Kentzo
Created April 14, 2014 02:37
Show Gist options
  • Save Kentzo/10611924 to your computer and use it in GitHub Desktop.
Save Kentzo/10611924 to your computer and use it in GitHub Desktop.
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