Make hb-diff faster
This commit is contained in:
parent
a93e238e05
commit
7d22135b4c
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import sys, os, re, difflib, unicodedata, errno
|
import sys, os, re, difflib, unicodedata, errno
|
||||||
|
from itertools import *
|
||||||
|
|
||||||
class Colors:
|
class Colors:
|
||||||
class Null:
|
class Null:
|
||||||
|
@ -91,7 +92,7 @@ class FancyDiffer:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def diff_files (f1, f2, colors=Colors.Null):
|
def diff_files (f1, f2, colors=Colors.Null):
|
||||||
try:
|
try:
|
||||||
for (l1,l2) in zip (f1, f2):
|
for (l1,l2) in izip (f1, f2):
|
||||||
if l1 == l2:
|
if l1 == l2:
|
||||||
sys.stdout.writelines ([" ", l1])
|
sys.stdout.writelines ([" ", l1])
|
||||||
continue
|
continue
|
||||||
|
@ -100,7 +101,7 @@ class FancyDiffer:
|
||||||
# print out residues
|
# print out residues
|
||||||
for l in f1:
|
for l in f1:
|
||||||
sys.stdout.writelines (["-", colors.red, l, colors.end])
|
sys.stdout.writelines (["-", colors.red, l, colors.end])
|
||||||
for l in f1:
|
for l in f2:
|
||||||
sys.stdout.writelines (["-", colors.green, l, colors.end])
|
sys.stdout.writelines (["-", colors.green, l, colors.end])
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
if e.errno != errno.EPIPE:
|
if e.errno != errno.EPIPE:
|
||||||
|
@ -114,6 +115,7 @@ class DiffFilters:
|
||||||
def filter_failures (f):
|
def filter_failures (f):
|
||||||
for l in f:
|
for l in f:
|
||||||
if l[0] in '-+':
|
if l[0] in '-+':
|
||||||
|
# TODO retain all lines of the failure
|
||||||
yield l
|
yield l
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue