Drop colordiff, implement it in PgDiff directly.
authorRadek Brich <radek.brich@devl.cz>
Thu, 31 Jan 2013 13:41:48 +0100
changeset 64 687e18e5ca93
parent 63 8c7f0a51ba50
child 65 ea79c89e9517
Drop colordiff, implement it in PgDiff directly.
pgtoolkit/colordiff.py
pgtoolkit/pgdiff.py
--- a/pgtoolkit/colordiff.py	Thu Jan 31 13:24:57 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-from subprocess import Popen, PIPE
-
-
-def colordiff(diff):
-    """Colorize diff output using external program colordiff"""
-    try:
-        p = Popen(["colordiff"], stdin=PIPE, stdout=PIPE, close_fds=True)
-        outs, _errs = p.communicate(diff.encode('utf8'))
-        return outs.decode('utf8')
-    except OSError:
-        return diff
-
--- a/pgtoolkit/pgdiff.py	Thu Jan 31 13:24:57 2013 +0100
+++ b/pgtoolkit/pgdiff.py	Thu Jan 31 13:41:48 2013 +0100
@@ -26,7 +26,6 @@
 
 
 from pgtoolkit.highlight import *
-from pgtoolkit.colordiff import colordiff
 
 import re
 import difflib
@@ -158,10 +157,9 @@
                     for line in difflib.unified_diff(a, b, lineterm=''):
                         if line[:3] in ('---', '+++'):
                             continue
-                        lines.append(line + '\n')
-                    diff = ''.join(lines)
-                    diff = colordiff(diff)
-                    res.append(diff)
+                        color = {' ': WHITE, '-': YELLOW, '+': GREEN, '@': WHITE|BOLD}[line[0]]
+                        lines.append(highlight(1, color) + line + highlight(0) + '\n')
+                    res.append(''.join(lines))
                 else:
                     res.append('Source differs.')
             else: