'Return enumerated columns of the remote database.'

def getcolumns(self, data):

    columns = defaultdict((lambda : defaultdict(list)))
    current_table = current_database = None
    status = 'find_log_line'
    list_start_count = 0
    list_found = False
    for line in data.splitlines():
        if (status == 'find_log_line'):
            if self._is_columns_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):
                list_found = True
                current_database = database
                status = 'find_table_name'
        elif (status == 'find_table_name'):
            table = self._match_start_get_remaining('Table:    ', line)
            if (database is not None):
                current_table = table
                status = 'find_two_list_starts'
        elif (status == 'find_two_list_starts'):
            if re.match('^\\+[\\-\\+]+\\+$', line):
                list_start_count += 1
                if (list_start_count == 2):
                    list_start_count = 0
                    status = 'find_columns'
        elif (status == 'find_columns'):
            if (line.startswith('|') and line.endswith('|')):
                (name, type_) = [val.strip() for val in line[1:(-1)].split('|')]
                columns[current_database][current_table].append((name, type_))
            elif re.match('^\\+[\\-\\+]+\\+$', line):
                status = 'find_dbname'
        else:
            raise RuntimeError('unknown    status')
    return columns
