code: def __driver_completer(self, toks, text, state):
          
          if state != 0:
              return self.__completion_candidates[state]
  
          # Update the cache when this method is first called, i.e., state == 0.
  
          # If the line is empty or the user is still inputing the first token,
          # complete with available commands.
          if not toks or (len(toks) == 1 and text == toks[0]):
              try:
                  self.__completion_candidates = self.__complete_cmds(text)
              except:
                  self.stderr.write('\n')
                  self.stderr.write(traceback.format_exc())
                  self.__completion_candidates = []
              return self.__completion_candidates[state]
  
          # Otherwise, try to complete with the registered completer method.
          cmd = toks[0]
          args = toks[1:] if len(toks) > 1 else None
          if text and args:
              del args[-1]
          if cmd in self._completer_map.keys():
              completer_name = self._completer_map[cmd]
              completer_method = getattr(self, completer_name)
              try:
                  self.__completion_candidates = completer_method(cmd, args, text)
              except:
                  self.stderr.write('\n')
                  self.stderr.write(traceback.format_exc())
                  self.__completion_candidates = []
          else:
              self.__completion_candidates = []
  
          return self.__completion_candidates[state]
docs: Driver level completer.
  
          Arguments:
              toks: A list of tokens, tokenized from the original input line.
              text: A string, the text to be replaced if a completion candidate is
                  chosen.
              state: An integer, the index of the candidate out of the list of
                  candidates.
  
          Returns:
              A string, the candidate.