Mercurial > kallithea
diff rhodecode/lib/dbmigrate/migrate/versioning/schemadiff.py @ 1203:6832ef664673 beta
source code cleanup: remove trailing white space, normalize file endings
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 03 Apr 2011 18:23:15 +0200 |
parents | 08d2dcd71666 |
children | 5b2cf21b1947 |
line wrap: on
line diff
--- a/rhodecode/lib/dbmigrate/migrate/versioning/schemadiff.py Sun Apr 03 12:43:29 2011 +0200 +++ b/rhodecode/lib/dbmigrate/migrate/versioning/schemadiff.py Sun Apr 03 18:23:15 2011 +0200 @@ -39,11 +39,11 @@ Container for differences in one :class:`~sqlalchemy.schema.Column` between two :class:`~sqlalchemy.schema.Table` instances, ``A`` and ``B``. - + .. attribute:: col_A The :class:`~sqlalchemy.schema.Column` object for A. - + .. attribute:: col_B The :class:`~sqlalchemy.schema.Column` object for B. @@ -51,15 +51,15 @@ .. attribute:: type_A The most generic type of the :class:`~sqlalchemy.schema.Column` - object in A. - + object in A. + .. attribute:: type_B The most generic type of the :class:`~sqlalchemy.schema.Column` - object in A. - + object in A. + """ - + diff = False def __init__(self,col_A,col_B): @@ -87,10 +87,10 @@ if not (A is None or B is None) and A!=B: self.diff=True return - + def __nonzero__(self): return self.diff - + class TableDiff(object): """ Container for differences in one :class:`~sqlalchemy.schema.Table` @@ -101,12 +101,12 @@ A sequence of column names that were found in B but weren't in A. - + .. attribute:: columns_missing_from_B A sequence of column names that were found in A but weren't in B. - + .. attribute:: columns_different A dictionary containing information about columns that were @@ -126,7 +126,7 @@ self.columns_missing_from_B or self.columns_different ) - + class SchemaDiff(object): """ Compute the difference between two :class:`~sqlalchemy.schema.MetaData` @@ -139,34 +139,34 @@ The length of a :class:`SchemaDiff` will give the number of changes found, enabling it to be used much like a boolean in expressions. - + :param metadataA: First :class:`~sqlalchemy.schema.MetaData` to compare. - + :param metadataB: Second :class:`~sqlalchemy.schema.MetaData` to compare. - + :param labelA: The label to use in messages about the first - :class:`~sqlalchemy.schema.MetaData`. - - :param labelB: + :class:`~sqlalchemy.schema.MetaData`. + + :param labelB: The label to use in messages about the second - :class:`~sqlalchemy.schema.MetaData`. - + :class:`~sqlalchemy.schema.MetaData`. + :param excludeTables: A sequence of table names to exclude. - + .. attribute:: tables_missing_from_A A sequence of table names that were found in B but weren't in A. - + .. attribute:: tables_missing_from_B A sequence of table names that were found in A but weren't in B. - + .. attribute:: tables_different A dictionary containing information about tables that were found @@ -195,26 +195,26 @@ self.tables_missing_from_B = sorted( A_table_names - B_table_names - excludeTables ) - + self.tables_different = {} for table_name in A_table_names.intersection(B_table_names): td = TableDiff() - + A_table = metadataA.tables[table_name] B_table = metadataB.tables[table_name] - + A_column_names = set(A_table.columns.keys()) B_column_names = set(B_table.columns.keys()) td.columns_missing_from_A = sorted( B_column_names - A_column_names ) - + td.columns_missing_from_B = sorted( A_column_names - B_column_names ) - + td.columns_different = {} for col_name in A_column_names.intersection(B_column_names): @@ -226,7 +226,7 @@ if cd: td.columns_different[col_name]=cd - + # XXX - index and constraint differences should # be checked for here @@ -237,7 +237,7 @@ ''' Summarize differences. ''' out = [] column_template =' %%%is: %%r' % self.label_width - + for names,label in ( (self.tables_missing_from_A,self.labelA), (self.tables_missing_from_B,self.labelB), @@ -248,7 +248,7 @@ label,', '.join(sorted(names)) ) ) - + for name,td in sorted(self.tables_different.items()): out.append( ' table with differences: %s' % name @@ -267,7 +267,7 @@ out.append(' column with differences: %s' % name) out.append(column_template % (self.labelA,cd.col_A)) out.append(column_template % (self.labelB,cd.col_B)) - + if out: out.insert(0, 'Schema diffs:') return '\n'.join(out)