def _get_or_define_module(full_name, modules):
 module = modules.get(full_name)
 if (not module):
  module = new.module(full_name)
  modules[full_name] = module
  split_name = full_name.rsplit('.', 1)
  if (len(split_name) > 1):
   (parent_module_name, sub_module_name) = split_name
   parent_module = _get_or_define_module(parent_module_name, modules)
   setattr(parent_module, sub_module_name, module)
 return module

def _get_or_define_module ( full_name , modules ) : module = modules . get ( full_name ) if ( not module ) : module = new . module ( full_name ) modules [ full_name ] = module split_name = full_name . rsplit ( '.' , 1 ) if ( len ( split_name ) > 1 ) : ( parent_module_name , sub_module_name ) = split_name parent_module = _get_or_define_module ( parent_module_name , modules ) setattr ( parent_module , sub_module_name , module ) return module
helper method for defining new modules .