forked from FabriceSalvaire/CodeReview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_Diff.py
More file actions
executable file
·47 lines (32 loc) · 1.58 KB
/
test_Diff.py
File metadata and controls
executable file
·47 lines (32 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /usr/bin/env python
# -*- Mode: Python -*-
#####################################################################################################
import argparse
import sys
#####################################################################################################
from Diff import FileDiffBuffer, Diff2Way
#####################################################################################################
parser = argparse.ArgumentParser(description='Patience Diff.')
parser.add_argument('file_a', metavar='File_a',
help='')
parser.add_argument('file_b', metavar='File_b',
help='')
parser.add_argument('--patience', dest='matcher',
action='store_const', const='patience', default='patience',
help="Use the patience difference algorithm")
parser.add_argument('--difflib', dest='matcher',
action='store_const', const='difflib', default='patience',
help="Use python\'s difflib algorithm")
args = parser.parse_args()
#####################################################################################################
file_a = open(args.file_a, 'rb').readlines()
file_b = open(args.file_b, 'rb').readlines()
diff_file_a = FileDiffBuffer(file_a, 'A')
diff_file_b = FileDiffBuffer(file_b, 'B')
diff2way = Diff2Way(diff_file_a, diff_file_b)
print diff2way.hunks
#####################################################################################################
#
# End
#
#####################################################################################################