pgtoolkit/colordiff.py
changeset 64 687e18e5ca93
parent 63 8c7f0a51ba50
child 65 ea79c89e9517
equal deleted inserted replaced
63:8c7f0a51ba50 64:687e18e5ca93
     1 from subprocess import Popen, PIPE
       
     2 
       
     3 
       
     4 def colordiff(diff):
       
     5     """Colorize diff output using external program colordiff"""
       
     6     try:
       
     7         p = Popen(["colordiff"], stdin=PIPE, stdout=PIPE, close_fds=True)
       
     8         outs, _errs = p.communicate(diff.encode('utf8'))
       
     9         return outs.decode('utf8')
       
    10     except OSError:
       
    11         return diff
       
    12