def _projectRow(self, i, project, topic):
        # Ensure that the row at i is the given project.  If the row
        # already exists somewhere in the list, delete all rows
        # between i and the row and then update the row.  If the row
        # does not exist, insert the row at position i.
        topic_key = topic and topic.key or None
        key = (topic_key, project.key)
        row = self.project_rows.get(key)
        while row:  # This is "if row: while True:".
            if i >= len(self.listbox.body):
                break
            current_row = self.listbox.body[i]
            if (isinstance(current_row, ProjectRow) and
                current_row.project_key == project.key):
                break
            self._deleteRow(current_row)
        if not row:
            row = ProjectRow(self.app, project, topic, self.onSelect)
            self.listbox.body.insert(i, row)
            self.project_rows[key] = row
        else:
            row.update(project)
        return i+1
dataset/ETHPy150Open openstack/gertty/gertty/view/project_list.py/ProjectListView._projectRow/original