420 " Overwrite it?</p>").format(fname), |
420 " Overwrite it?</p>").format(fname), |
421 icon=E5MessageBox.Warning) |
421 icon=E5MessageBox.Warning) |
422 if not res: |
422 if not res: |
423 return |
423 return |
424 |
424 |
|
425 fname = Utilities.toNativeSeparators(fname) |
425 try: |
426 try: |
426 f = open( |
427 with open(fname, "w", encoding="utf-8") as f: |
427 Utilities.toNativeSeparators(fname), "w", encoding="utf-8") |
428 f.write(self.regexpTextEdit.toPlainText()) |
428 f.write(self.regexpTextEdit.toPlainText()) |
|
429 f.close() |
|
430 except IOError as err: |
429 except IOError as err: |
431 E5MessageBox.information( |
430 E5MessageBox.information( |
432 self, |
431 self, |
433 self.tr("Save regular expression"), |
432 self.tr("Save regular expression"), |
434 self.tr("""<p>The regular expression could not""" |
433 self.tr("""<p>The regular expression could not""" |
444 self, |
443 self, |
445 self.tr("Load regular expression"), |
444 self.tr("Load regular expression"), |
446 "", |
445 "", |
447 self.tr("RegExp Files (*.rx);;All Files (*)")) |
446 self.tr("RegExp Files (*.rx);;All Files (*)")) |
448 if fname: |
447 if fname: |
|
448 fname = Utilities.toNativeSeparators(fname) |
449 try: |
449 try: |
450 f = open( |
450 with open(fname, "r", encoding="utf-8") as f: |
451 Utilities.toNativeSeparators(fname), "r", encoding="utf-8") |
451 regexp = f.read() |
452 regexp = f.read() |
|
453 f.close() |
|
454 self.regexpTextEdit.setPlainText(regexp) |
452 self.regexpTextEdit.setPlainText(regexp) |
455 except IOError as err: |
453 except IOError as err: |
456 E5MessageBox.information( |
454 E5MessageBox.information( |
457 self, |
455 self, |
458 self.tr("Save regular expression"), |
456 self.tr("Save regular expression"), |