pgtoolkit/pgdiff.py
changeset 64 687e18e5ca93
parent 63 8c7f0a51ba50
child 83 515fadd3d286
equal deleted inserted replaced
63:8c7f0a51ba50 64:687e18e5ca93
    24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    25 # THE SOFTWARE.
    25 # THE SOFTWARE.
    26 
    26 
    27 
    27 
    28 from pgtoolkit.highlight import *
    28 from pgtoolkit.highlight import *
    29 from pgtoolkit.colordiff import colordiff
       
    30 
    29 
    31 import re
    30 import re
    32 import difflib
    31 import difflib
    33 
    32 
    34 
    33 
   156                 if self.show_body_diff:
   155                 if self.show_body_diff:
   157                     lines = ['Source differs:\n']
   156                     lines = ['Source differs:\n']
   158                     for line in difflib.unified_diff(a, b, lineterm=''):
   157                     for line in difflib.unified_diff(a, b, lineterm=''):
   159                         if line[:3] in ('---', '+++'):
   158                         if line[:3] in ('---', '+++'):
   160                             continue
   159                             continue
   161                         lines.append(line + '\n')
   160                         color = {' ': WHITE, '-': YELLOW, '+': GREEN, '@': WHITE|BOLD}[line[0]]
   162                     diff = ''.join(lines)
   161                         lines.append(highlight(1, color) + line + highlight(0) + '\n')
   163                     diff = colordiff(diff)
   162                     res.append(''.join(lines))
   164                     res.append(diff)
       
   165                 else:
   163                 else:
   166                     res.append('Source differs.')
   164                     res.append('Source differs.')
   167             else:
   165             else:
   168                 res.append(''.join(['Changed ', type, ' from ',
   166                 res.append(''.join(['Changed ', type, ' from ',
   169                     highlight(1,15), a, highlight(0), ' to ',
   167                     highlight(1,15), a, highlight(0), ' to ',