Skip to content

Commit

Permalink
STYLE: slicer.util.importModuleObjects: Simplify code
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.slicer.org/Slicer4/trunk@25114 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information
jcfr committed May 23, 2016
1 parent b978865 commit acda657
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Base/Python/slicer/util.py
Expand Up @@ -80,21 +80,20 @@ def importModuleObjects(from_module_name, dest_module_name, type_name):
import sys
dest_module = sys.modules[dest_module_name]

exec "import %s" % (from_module_name)
# Obtain a reference to the module identified by 'from_module_name'
import imp
fp, pathname, description = imp.find_module(from_module_name)
module = imp.load_module(from_module_name, fp, pathname, description)

# Obtain a reference to the associated VTK module
module = eval(from_module_name)

# Loop over content of the python module associated with the given VTK python library
# Loop over content of the python module associated with the given python library
for item_name in dir(module):

# Obtain a reference associated with the current object
item = eval("%s.%s" % (from_module_name, item_name))
item = getattr(module, item_name)

# Add the object to dest_module_globals_dict if any
if type(item).__name__ == type_name:
exec("from %s import %s" % (from_module_name, item_name))
exec("dest_module.%s = %s"%(item_name, item_name))
setattr(dest_module, item_name, item)

#
# UI
Expand Down

0 comments on commit acda657

Please sign in to comment.