parameters: (obj_to_complete, dirComps=None, getattr=getattr, filter=lambda name:True)
return_statement: return ret
docstring: @param obj_to_complete: the object from where we should get the completions
          @param dirComps: if passed, we should not 'dir' the object and should just iterate those passed as a parameter
          @param getattr: the way to get a given object from the obj_to_complete (used for the completer)
          @param filter: a callable that receives the name and decides if it should be appended or not to the results
          @return: list of tuples, so that each tuple represents a completion with:
              name, doc, args, type (from the TYPE_* constants)
function: def GenerateImportsTipForModule(obj_to_complete, dirComps=None, getattr=getattr, filter=lambda name:True):
      '''
          @param obj_to_complete: the object from where we should get the completions
          @param dirComps: if passed, we should not 'dir' the object and should just iterate those passed as a parameter
          @param getattr: the way to get a given object from the obj_to_complete (used for the completer)
          @param filter: a callable that receives the name and decides if it should be appended or not to the results
          @return: list of tuples, so that each tuple represents a completion with:
              name, doc, args, type (from the TYPE_* constants)
      '''
      ret = []
  
      if dirComps is None:
          dirComps = dir(obj_to_complete)
          if hasattr(obj_to_complete, '__dict__'):
              dirComps.append('__dict__')
          if hasattr(obj_to_complete, '__class__'):
              dirComps.append('__class__')
  
      getCompleteInfo = True
  
      if len(dirComps) > 1000:
          # ok, we don't want to let our users wait forever...
          # no complete info for you...
  
          getCompleteInfo = False
  
      dontGetDocsOn = (float, int, str, tuple, list)
      for d in dirComps:
  
          if d is None:
              continue
  
          if not filter(d):
              continue
  
          args = ''
  
          try:
              obj = getattr(obj_to_complete, d)
          except:  # just ignore and get it without aditional info
              ret.append((d, '', args, TYPE_BUILTIN))
          else:
  
              if getCompleteInfo:
                  retType = TYPE_BUILTIN
  
                  # check if we have to get docs
                  getDoc = True
                  for class_ in dontGetDocsOn:
  
                      if isinstance(obj, class_):
                          getDoc = False
                          break
  
                  doc = ''
                  if getDoc:
                      # no need to get this info... too many constants are defined and
                      # makes things much slower (passing all that through sockets takes quite some time)
                      try:
                          doc = inspect.getdoc(obj)
                          if doc is None:
                              doc = ''
                      except:  # may happen on jython when checking java classes (so, just ignore it)
                          doc = ''
  
  
                  if inspect.ismethod(obj) or inspect.isbuiltin(obj) or inspect.isfunction(obj) or inspect.isroutine(obj):
                      try:
                          args, vargs, kwargs, defaults = inspect.getargspec(obj)
                      except:
                          args, vargs, kwargs, defaults = (('self',), None, None, None)
                      if defaults is not None:
                          start_defaults_at = len(args) - len(defaults)
  
  
                      r = ''
                      for i, a in enumerate(args):
  
                          if len(r) > 0:
                              r = r + ', '
  
                          r = r + str(a)
  
                          if defaults is not None and i >= start_defaults_at:
                              default =  defaults[i - start_defaults_at]
                              r += '=' +str(default)
  
  
                      others = ''
                      if vargs:
                          others += '*' + vargs
  
                      if kwargs:
                          if others:
                              others+= ', '
                          others += '**' + kwargs
  
                      if others:
                          r+= ', '
  
  
                      args = '(%s%s)' % (r, others)
                      retType = TYPE_FUNCTION
  
                  elif inspect.isclass(obj):
                      retType = TYPE_CLASS
  
                  elif inspect.ismodule(obj):
                      retType = TYPE_IMPORT
  
                  else:
                      retType = TYPE_ATTR
  
  
                  # add token and doc to return - assure only strings.
                  ret.append((d, doc, args, retType))
  
  
              else:  # getCompleteInfo == False
                  if inspect.ismethod(obj) or inspect.isbuiltin(obj) or inspect.isfunction(obj) or inspect.isroutine(obj):
                      retType = TYPE_FUNCTION
  
                  elif inspect.isclass(obj):
                      retType = TYPE_CLASS
  
                  elif inspect.ismodule(obj):
                      retType = TYPE_IMPORT
  
                  else:
                      retType = TYPE_ATTR
                  # ok, no complete info, let's try to do this as fast and clean as possible
                  # so, no docs for this kind of information, only the signatures
                  ret.append((d, '', str(args), retType))
  
      return ret
function_tokens: def GenerateImportsTipForModule ( obj_to_complete , dirComps = None , getattr = getattr , filter = lambda name : True ) : ret = [ ] if dirComps is None : dirComps = dir ( obj_to_complete ) if hasattr ( obj_to_complete , '__dict__' ) : dirComps . append ( '__dict__' ) if hasattr ( obj_to_complete , '__class__' ) : dirComps . append ( '__class__' ) getCompleteInfo = True if len ( dirComps ) > 1000 : # ok, we don't want to let our users wait forever... # no complete info for you... getCompleteInfo = False dontGetDocsOn = ( float , int , str , tuple , list ) for d in dirComps : if d is None : continue if not filter ( d ) : continue args = '' try : obj = getattr ( obj_to_complete , d ) except : # just ignore and get it without aditional info ret . append ( ( d , '' , args , TYPE_BUILTIN ) ) else : if getCompleteInfo : retType = TYPE_BUILTIN # check if we have to get docs getDoc = True for class_ in dontGetDocsOn : if isinstance ( obj , class_ ) : getDoc = False break doc = '' if getDoc : # no need to get this info... too many constants are defined and # makes things much slower (passing all that through sockets takes quite some time) try : doc = inspect . getdoc ( obj ) if doc is None : doc = '' except : # may happen on jython when checking java classes (so, just ignore it) doc = '' if inspect . ismethod ( obj ) or inspect . isbuiltin ( obj ) or inspect . isfunction ( obj ) or inspect . isroutine ( obj ) : try : args , vargs , kwargs , defaults = inspect . getargspec ( obj ) except : args , vargs , kwargs , defaults = ( ( 'self' , ) , None , None , None ) if defaults is not None : start_defaults_at = len ( args ) - len ( defaults ) r = '' for i , a in enumerate ( args ) : if len ( r ) > 0 : r = r + ', ' r = r + str ( a ) if defaults is not None and i >= start_defaults_at : default = defaults [ i - start_defaults_at ] r += '=' + str ( default ) others = '' if vargs : others += '*' + vargs if kwargs : if others : others += ', ' others += '**' + kwargs if others : r += ', ' args = '(%s%s)' % ( r , others ) retType = TYPE_FUNCTION elif inspect . isclass ( obj ) : retType = TYPE_CLASS elif inspect . ismodule ( obj ) : retType = TYPE_IMPORT else : retType = TYPE_ATTR # add token and doc to return - assure only strings. ret . append ( ( d , doc , args , retType ) ) else : # getCompleteInfo == False if inspect . ismethod ( obj ) or inspect . isbuiltin ( obj ) or inspect . isfunction ( obj ) or inspect . isroutine ( obj ) : retType = TYPE_FUNCTION elif inspect . isclass ( obj ) : retType = TYPE_CLASS elif inspect . ismodule ( obj ) : retType = TYPE_IMPORT else : retType = TYPE_ATTR # ok, no complete info, let's try to do this as fast and clean as possible # so, no docs for this kind of information, only the signatures ret . append ( ( d , '' , str ( args ) , retType ) ) return ret