14 from PyQt4.QtCore import * |
14 from PyQt4.QtCore import * |
15 from PyQt4.QtGui import * |
15 from PyQt4.QtGui import * |
16 |
16 |
17 from E4Gui.E4Completers import E4FileCompleter |
17 from E4Gui.E4Completers import E4FileCompleter |
18 |
18 |
19 from Ui_DiffDialog import Ui_DiffDialog |
19 from .Ui_DiffDialog import Ui_DiffDialog |
20 import Utilities |
20 import Utilities |
21 |
21 |
22 from difflib import SequenceMatcher |
22 from difflib import SequenceMatcher |
23 |
23 |
24 # This function is copied from python 2.3 and slightly modified. |
24 # This function is copied from python 2.3 and slightly modified. |
298 if res != QMessageBox.Save: |
298 if res != QMessageBox.Save: |
299 return |
299 return |
300 fname = Utilities.toNativeSeparators(fname) |
300 fname = Utilities.toNativeSeparators(fname) |
301 |
301 |
302 try: |
302 try: |
303 f = open(fname, "wb") |
303 f = open(fname, "w") |
304 txt = self.contents.toPlainText() |
304 txt = self.contents.toPlainText() |
305 try: |
305 try: |
306 f.write(txt) |
306 f.write(txt) |
307 except UnicodeError: |
307 except UnicodeError: |
308 pass |
308 pass |
309 f.close() |
309 f.close() |
310 except IOError, why: |
310 except IOError as why: |
311 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
311 QMessageBox.critical(self, self.trUtf8('Save Diff'), |
312 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.<br />' |
312 self.trUtf8('<p>The patch file <b>{0}</b> could not be saved.<br />' |
313 'Reason: {1}</p>') |
313 'Reason: {1}</p>') |
314 .format(fname, unicode(why))) |
314 .format(fname, str(why))) |
315 |
315 |
316 @pyqtSlot() |
316 @pyqtSlot() |
317 def on_diffButton_clicked(self): |
317 def on_diffButton_clicked(self): |
318 """ |
318 """ |
319 Private slot to handle the Compare button press. |
319 Private slot to handle the Compare button press. |