pgtoolkit/colordiff.py
changeset 63 8c7f0a51ba50
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pgtoolkit/colordiff.py	Thu Jan 31 13:24:57 2013 +0100
@@ -0,0 +1,12 @@
+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
+