'Return enumerated tables of the remote database.'

def gettables(self, data):

    tables = defaultdict(list)
    current_database = None
    status = 'find_log_line'
    list_found = False
    for line in data.splitlines():
        if (status == 'find_log_line'):
            if self._is_tables_log_line(line):
                status = 'find_dbname'
        elif (self._is_log_and_startswith('', line) and list_found):
            break
        elif (status == 'find_dbname'):
            database = self._match_start_get_remaining('Database:    ', line)
            if (database is not None):
                current_database = database
                list_found = True
                status = 'find_list_start'
        elif (status == 'find_list_start'):
            if re.match('^\\+\\-+\\+$', line):
                status = 'find_tables'
        elif (status == 'find_tables'):
            if (line.startswith('|') and line.endswith('|')):
                table = line[1:(-1)].strip()
                tables[current_database].append(table)
            elif re.match('^\\+\\-+\\+$', line):
                status = 'find_dbname'
        else:
            raise RuntimeError('unknown    status')
    return tables
