64 |
64 |
65 for (ln1, l1), (ln2, l2), flag in _mdiff(a, b, None, None, |
65 for (ln1, l1), (ln2, l2), flag in _mdiff(a, b, None, None, |
66 IS_CHARACTER_JUNK): |
66 IS_CHARACTER_JUNK): |
67 if not flag: |
67 if not flag: |
68 yield ('e', linenumberformat.format(ln1), l1, |
68 yield ('e', linenumberformat.format(ln1), l1, |
69 linenumberformat.format(ln2), l2) |
69 linenumberformat.format(ln2), l2) |
70 continue |
70 continue |
71 if ln2 == "" and l2 == "\n": |
71 if ln2 == "" and l2 == "\n": |
72 yield ('d', linenumberformat.format(ln1), removeMarkers(l1), |
72 yield ('d', linenumberformat.format(ln1), removeMarkers(l1), |
73 emptylineno, '\n') |
73 emptylineno, '\n') |
74 continue |
74 continue |
75 if ln1 == "" and l1 == "\n": |
75 if ln1 == "" and l1 == "\n": |
76 yield ('i', emptylineno, '\n', |
76 yield ('i', emptylineno, '\n', |
77 linenumberformat.format(ln2), removeMarkers(l2)) |
77 linenumberformat.format(ln2), removeMarkers(l2)) |
78 continue |
78 continue |
79 yield ('r', linenumberformat.format(ln1), l1, |
79 yield ('r', linenumberformat.format(ln1), l1, |
80 linenumberformat.format(ln2), l2) |
80 linenumberformat.format(ln2), l2) |
81 |
81 |
82 |
82 |
83 class CompareDialog(QWidget, Ui_CompareDialog): |
83 class CompareDialog(QWidget, Ui_CompareDialog): |
84 """ |
84 """ |
85 Class implementing a dialog to compare two files and show the result side |
85 Class implementing a dialog to compare two files and show the result side |
232 E5MessageBox.critical( |
232 E5MessageBox.critical( |
233 self, |
233 self, |
234 self.trUtf8("Compare Files"), |
234 self.trUtf8("Compare Files"), |
235 self.trUtf8( |
235 self.trUtf8( |
236 """<p>The file <b>{0}</b> could not be read.</p>""") |
236 """<p>The file <b>{0}</b> could not be read.</p>""") |
237 .format(filename1)) |
237 .format(filename1)) |
238 return |
238 return |
239 |
239 |
240 filename2 = Utilities.toNativeSeparators(self.file2Edit.text()) |
240 filename2 = Utilities.toNativeSeparators(self.file2Edit.text()) |
241 try: |
241 try: |
242 f2 = open(filename2, "r", encoding="utf-8") |
242 f2 = open(filename2, "r", encoding="utf-8") |
246 E5MessageBox.critical( |
246 E5MessageBox.critical( |
247 self, |
247 self, |
248 self.trUtf8("Compare Files"), |
248 self.trUtf8("Compare Files"), |
249 self.trUtf8( |
249 self.trUtf8( |
250 """<p>The file <b>{0}</b> could not be read.</p>""") |
250 """<p>The file <b>{0}</b> could not be read.</p>""") |
251 .format(filename2)) |
251 .format(filename2)) |
252 return |
252 return |
253 |
253 |
254 self.__compare(lines1, lines2) |
254 self.__compare(lines1, lines2) |
255 |
255 |
256 def compare(self, lines1, lines2, name1="", name2=""): |
256 def compare(self, lines1, lines2, name1="", name2=""): |