LEFT | RIGHT |
1 #!@PYTHON@ | 1 #!@PYTHON@ |
| 2 import codecs |
2 import errno | 3 import errno |
3 import sys | 4 import sys |
4 import optparse | 5 import optparse |
5 import os | 6 import os |
6 import math | 7 import math |
7 import re | 8 import re |
8 | 9 |
9 import html | 10 import html |
10 from functools import reduce | 11 from functools import reduce |
11 | 12 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 ## what & where changed. | 486 ## what & where changed. |
486 | 487 |
487 if self.contents[0] == self.contents[1]: | 488 if self.contents[0] == self.contents[1]: |
488 return 0.0 | 489 return 0.0 |
489 else: | 490 else: |
490 return 100.0; | 491 return 100.0; |
491 | 492 |
492 def get_content (self, name): | 493 def get_content (self, name): |
493 log_verbose ('reading %s' % name) | 494 log_verbose ('reading %s' % name) |
494 try: | 495 try: |
495 f = open (name) | 496 return codecs.open (name, 'r', 'utf-8').read () |
496 except IOError as e: | 497 except IOError as e: |
497 if e.errno == errno.ENOENT: | 498 if e.errno == errno.ENOENT: |
498 return None | 499 return None |
499 else: | 500 else: |
500 raise | 501 raise |
501 s = f.read () | |
502 return s | |
503 | 502 |
504 | 503 |
505 class GitFileCompareLink (FileCompareLink): | 504 class GitFileCompareLink (FileCompareLink): |
506 def get_cell (self, oldnew): | 505 def get_cell (self, oldnew): |
507 str = self.contents[oldnew] | 506 str = self.contents[oldnew] |
508 | 507 |
509 # truncate long lines | 508 # truncate long lines |
510 str = '\n'.join ([l[:80] for l in str.split ('\n')]) | 509 str = '\n'.join ([l[:80] for l in str.split ('\n')]) |
511 | 510 |
512 if str: | 511 if str: |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 for (key, val) in list(self.file_links.items ()): | 932 for (key, val) in list(self.file_links.items ()): |
934 | 933 |
935 def note_original (match, ln=val): | 934 def note_original (match, ln=val): |
936 key = ln.name () | 935 key = ln.name () |
937 hash_to_original_name[key] = match.group (1) | 936 hash_to_original_name[key] = match.group (1) |
938 return '' | 937 return '' |
939 | 938 |
940 sf = val.source_file () | 939 sf = val.source_file () |
941 if sf: | 940 if sf: |
942 re.sub (r'\\sourcefilename "([^"]+)"', | 941 re.sub (r'\\sourcefilename "([^"]+)"', |
943 note_original, open (sf).read ()) | 942 note_original, codecs.open (sf, 'r', 'utf-8').read ()) |
944 else: | 943 else: |
945 print('no source for', val.file_names[1]) | 944 print('no source for', val.file_names[1]) |
946 | 945 |
947 def compare_trees (self, dir1, dir2): | 946 def compare_trees (self, dir1, dir2): |
948 self.compare_directories (dir1, dir2) | 947 self.compare_directories (dir1, dir2) |
949 | 948 |
950 try: | 949 try: |
951 (root, dirs, files) = next(os.walk (dir1)) | 950 (root, dirs, files) = next(os.walk (dir1)) |
952 except StopIteration: | 951 except StopIteration: |
953 if dir1.endswith("-baseline"): | 952 if dir1.endswith("-baseline"): |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 out = options.output_dir | 1597 out = options.output_dir |
1599 if not out: | 1598 if not out: |
1600 out = args[0].replace ('/', '') | 1599 out = args[0].replace ('/', '') |
1601 out = os.path.join (args[1], 'compare-' + shorten_string (out)) | 1600 out = os.path.join (args[1], 'compare-' + shorten_string (out)) |
1602 | 1601 |
1603 compare_tree_pairs (list(zip(args[0::2], args[1::2])), out, options.threshol
d) | 1602 compare_tree_pairs (list(zip(args[0::2], args[1::2])), out, options.threshol
d) |
1604 | 1603 |
1605 if __name__ == '__main__': | 1604 if __name__ == '__main__': |
1606 main () | 1605 main () |
1607 | 1606 |
LEFT | RIGHT |