def update_columns(self, new_dicts): # Match up the columns with their new dictionaries. align_key = lambda col, new_dict: col.id == new_dict['id'] updates = align.align_right(self.columns, new_dicts, align_key) # Update existing rows map(lambda (col, new_dict): col.update_from_dict(new_dict) if col else None, updates) '''Put existing, updated rows back into self.rows and instantiate new rows''' self.columns = [col if col else SmartColumn(new_dict) for (col, new_dict) in updates] self.columns.sort(key = lambda col: col.id)
def update_rows(self, new_dicts): # Match up the rows with their new dictionaries. align_key = lambda row, new_dict: row.id == new_dict['id'] updates = align.align_right(self.rows, new_dicts, align_key) # Update existing rows map(lambda (row, new_dict): row.update_from_dict(new_dict) if row is not None else None, updates) '''Put existing, updated rows back into self.rows and instantiate new rows''' self.rows = [row if row else SmartRow(self, new_dict) for (row, new_dict) in updates] self.rows.sort(key = lambda row: row.id)