%s
\n\n' % remark) add('| Field | \n\n') add('Type | \n\n') add('Default | \n\n') add('Properties | \n\n') add('Remarks | \n\n') add('
|---|
| Name | \n\n') add('Fields | \n\n') add('Properties | \n\n') add('Remarks | \n\n') add('
|---|
| \n\n'
tables_table += '
Indexes:
\n\n') output_indexes(table, colour, indexes, colours[table]['index'], dict, bugzilla_versions) else: add('The "%s" table has no indexes.
' % table) tables_tables(tables_table_rows, quick_tables_table_rows, dict) return (dict, body) # 6. Code to read all the database schemas and figure out the history # from that. # colours of tables, and rows, and entries red = ' bgcolor="#ffcccc"' # no longer present green = ' bgcolor="#ccffcc"' # no longer absent blue = ' bgcolor="#ccccff"' # changed white = '' # no colour # colours: {table: {'': table colour, # 'column': {column: {'': column colour, # field: field colour}}, # 'index': {index: {'': index colour, # field: field colour}), # }} def init_colours(colours, t, cols, inds): if not colours.has_key(t): colours[t] = {'': white} colours[t]['column'] = {} colours[t]['index'] = {} for c in cols: if not colours[t]['column'].has_key(c): colours[t]['column'][c] = {} for k in ['', 'Name', 'Default', 'Type', 'Properties', 'Remarks']: colours[t]['column'][c][k] = white for i in inds: if not colours[t]['index'].has_key(i): colours[t]['index'][i] = {'': white} for k in ['', 'Name', 'Fields', 'Properties', 'Remarks']: colours[t]['index'][i][k] = white # any table can omit an entry at any level, meaning 'the same as other # entries at this level'. # For a field which can change (e.g. the Type of a column), we store # it during processing as a list of pairs: # # [(first bugzilla version, value), ...] # # So list[-1][1] is the current value. When we're done figuring out # the schema history, we replace this list with a single value. # Make the initial pair lists for a column. def pair_up_column_entries(bz, column): for k in ['Name', 'Type', 'Default', 'Properties']: column[k] = [(bz, column[k])] # Make the initial pair lists for an index. def pair_up_index_entries(bz, index): for k in ['Name', 'Fields', 'Properties']: index[k] = [(bz, index[k])] # Make all the initial pair lists for a table. def pair_up_table_entries(bz, schema, table): (columns, indexes) = schema[table] for c in columns.values(): pair_up_column_entries(bz, c) for i in indexes.values(): pair_up_index_entries(bz, i) def pair_up_schema(bz, schema): for t in schema.keys(): pair_up_table_entries(bz, schema, t) # Given a pair list, make a single value which explains the history. # I've tried various ways of showing this; this is the best I've come # up with. def reduce_pair_list(pl): current = None last_change = None changes = [] for p in pl: if p[1] == current: continue current = p[1] last_change = p[0] changes.append((last_change, current)) return changes def stringify_pairs(pl): changes = reduce_pair_list(pl) if len(changes) == 1: return changes[0][1] else: s = [] for c in changes: s.append('%s: %s'% (c[0], c[1])) return string.join(s, ';