12 |
12 |
13 from PyQt4.QtCore import * |
13 from PyQt4.QtCore import * |
14 from PyQt4.QtGui import * |
14 from PyQt4.QtGui import * |
15 |
15 |
16 from E5Gui.E5Completers import E5FileCompleter |
16 from E5Gui.E5Completers import E5FileCompleter |
|
17 from E5Gui import E5MessageBox |
17 |
18 |
18 from .Ui_DiffDialog import Ui_DiffDialog |
19 from .Ui_DiffDialog import Ui_DiffDialog |
19 import Utilities |
20 import Utilities |
20 |
21 |
21 from difflib import SequenceMatcher |
22 from difflib import SequenceMatcher |
304 f.write(txt) |
305 f.write(txt) |
305 except UnicodeError: |
306 except UnicodeError: |
306 pass |
307 pass |
307 f.close() |
308 f.close() |
308 except IOError as why: |
309 except IOError as why: |
309 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
310 E5MessageBox.critical(self, self.trUtf8('Save Diff'), |
310 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.<br />' |
311 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.<br />' |
311 'Reason: {1}</p>') |
312 'Reason: {1}</p>') |
312 .format(fname, str(why))) |
313 .format(fname, str(why))) |
313 |
314 |
314 @pyqtSlot() |
315 @pyqtSlot() |
324 try: |
325 try: |
325 f1 = open(self.filename1, "r", encoding = "utf-8") |
326 f1 = open(self.filename1, "r", encoding = "utf-8") |
326 lines1 = f1.readlines() |
327 lines1 = f1.readlines() |
327 f1.close() |
328 f1.close() |
328 except IOError: |
329 except IOError: |
329 QMessageBox.critical(self, |
330 E5MessageBox.critical(self, |
330 self.trUtf8("Compare Files"), |
331 self.trUtf8("Compare Files"), |
331 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
332 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
332 .format(self.filename1)) |
333 .format(self.filename1)) |
333 return |
334 return |
334 |
335 |
340 try: |
341 try: |
341 f2 = open(self.filename2, "r", encoding = "utf-8") |
342 f2 = open(self.filename2, "r", encoding = "utf-8") |
342 lines2 = f2.readlines() |
343 lines2 = f2.readlines() |
343 f2.close() |
344 f2.close() |
344 except IOError: |
345 except IOError: |
345 QMessageBox.critical(self, |
346 E5MessageBox.critical(self, |
346 self.trUtf8("Compare Files"), |
347 self.trUtf8("Compare Files"), |
347 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
348 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
348 .format(self.filename2)) |
349 .format(self.filename2)) |
349 return |
350 return |
350 |
351 |