diff -r 7f219da7ab71 -r 5fb4883604d6 pgtoolkit/pgdatadiff.py --- a/pgtoolkit/pgdatadiff.py Fri Jan 13 15:49:24 2012 +0100 +++ b/pgtoolkit/pgdatadiff.py Tue Feb 07 10:40:35 2012 +0100 @@ -34,7 +34,8 @@ '+' : BOLD | GREEN, '-' : BOLD | RED, '*' : BOLD | YELLOW, - 'V' : BOLD | WHITE} + 'V' : BOLD | WHITE, + 'K' : BOLD | BLUE} def __init__(self, change, cols1, cols2, id=None): self.change = change @@ -44,7 +45,7 @@ def format(self): out = [] - + out.append(highlight(1, self.COLORS[self.change])) out.extend([self.change, ' ']) @@ -62,20 +63,25 @@ return method[self.change](table) - def _format_changes(self): + def _format_changes(self): if self.cols1 and not self.cols2: return [', '.join([self._format_value_del(*x) for x in self.cols1.items()])] if not self.cols1 and self.cols2: return [', '.join([self._format_value_add(*x) for x in self.cols2.items()])] + out = [] + if self.id: + out.extend([highlight(1, self.COLORS['*']), self.id[0], ': ', highlight(0), self.id[1], ', ']) + items = [] for i in range(len(self.cols1)): items.append(( list(self.cols1.keys())[i], list(self.cols1.values())[i], list(self.cols2.values())[i])) - - return [', '.join([self._format_value_change(*x) for x in items])] + out.extend([', '.join([self._format_value_change(*x) for x in items])]) + + return out def _format_value_del(self, k, v): fs = (highlight(1, self.COLORS['-']) + '{}: ' + highlight(0) + '{}') @@ -191,6 +197,8 @@ def _select(self): browser = pgbrowser.PgBrowser(self.conn1) columns = browser.list_columns(schema=self.schema1, table=self.table1, order=1) + if not columns: + raise Exception('Table %s.%s not found.' % (self.schema1, self.table1)) columns_sel = ', '.join(['"' + x['name'] + '"' for x in columns]) self.colnames = [x['name'] for x in columns]