# -------------------------------------------------------------------------
# Class to hold details regarding a HTML table
# -------------------------------------------------------------------------


class TableDetails:

    def __init__(self):
        self.row_count = 0
        self.column_names = {}

    def add_column_name(self, index, name):
        """Adds a column to the table definition"""
        self.column_names[int(index)] = name

    def set_row_count(self, count):
        """Sets the row count of the table"""
        self.row_count = int(count)

    def get_column_index(self, name):
        """Gets the index position of a column with specified name"""
        for index, value in self.column_names.items():
            if value.lower() == name.lower():
                return index + 1
        raise Exception('No table column found with name: %s' % name)

    def get_row_count(self):
        """Gets the number of rows in the table"""
        return self.row_count

    def has_header_row(self):
        """Gets if table has a header row"""
        return len(self.column_names) > 0
