def autoimport():
 word = env.var('a:word')
 if (not word):
  env.error('Should be word under cursor.')
  return False
 with RopeContext() as ctx:
  if (not ctx.importer.names):
   ctx.generate_autoimport_cache()
  modules = ctx.importer.get_modules(word)
  if (not modules):
   env.message(('Global name %s not found.' % word))
   return False
  if (len(modules) == 1):
   _insert_import(word, modules[0], ctx)
  else:
   module = env.user_input_choices('Which module to import:', *modules)
   _insert_import(word, module, ctx)
  return True

def autoimport ( ) : word = env . var ( 'a:word' ) if ( not word ) : env . error ( 'Should be word under cursor.' ) return False with RopeContext ( ) as ctx : if ( not ctx . importer . names ) : ctx . generate_autoimport_cache ( ) modules = ctx . importer . get_modules ( word ) if ( not modules ) : env . message ( ( 'Global name %s not found.' % word ) ) return False if ( len ( modules ) == 1 ) : _insert_import ( word , modules [ 0 ] , ctx ) else : module = env . user_input_choices ( 'Which module to import:' , * modules ) _insert_import ( word , module , ctx ) return True
autoimport modules .