1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 19:09:21 +00:00

adding ability to provide diff command for #203

This commit is contained in:
deadc0de6
2020-01-22 17:41:48 +01:00
parent 0da393cef2
commit d4375c5d04
8 changed files with 153 additions and 20 deletions

View File

@@ -15,12 +15,12 @@ from dotdrop.utils import must_ignore, uniq_list, diff
class Comparator:
def __init__(self, diffopts='', debug=False):
def __init__(self, diff_cmd='', debug=False):
"""constructor
@diffopts: switches to pass to unix diff
@diff_cmd: diff command to use
@debug: enable debug
"""
self.diffopts = diffopts
self.diff_cmd = diff_cmd
self.debug = debug
self.log = Logger()
@@ -122,9 +122,9 @@ class Comparator:
return ''.join(ret)
def _diff(self, left, right, header=False):
"""diff using the unix tool diff"""
"""diff two files"""
out = diff(modified=left, original=right, raw=False,
opts=self.diffopts, debug=self.debug)
diff_cmd=self.diff_cmd, debug=self.debug)
if header:
lshort = os.path.basename(left)
out = '=> diff \"{}\":\n{}'.format(lshort, out)