338 " Overwrite it?</p>").format(fname), |
338 " Overwrite it?</p>").format(fname), |
339 icon=E5MessageBox.Warning) |
339 icon=E5MessageBox.Warning) |
340 if not res: |
340 if not res: |
341 return |
341 return |
342 |
342 |
|
343 fname = Utilities.toNativeSeparators(fname) |
343 try: |
344 try: |
344 f = open( |
345 with open(fname, "w", encoding="utf-8") as f: |
345 Utilities.toNativeSeparators(fname), "w", encoding="utf-8") |
346 f.write(self.regexpTextEdit.toPlainText()) |
346 f.write(self.regexpTextEdit.toPlainText()) |
|
347 f.close() |
|
348 except IOError as err: |
347 except IOError as err: |
349 E5MessageBox.information( |
348 E5MessageBox.information( |
350 self, |
349 self, |
351 self.tr("Save regular expression"), |
350 self.tr("Save regular expression"), |
352 self.tr("""<p>The regular expression could not""" |
351 self.tr("""<p>The regular expression could not""" |
362 self, |
361 self, |
363 self.tr("Load regular expression"), |
362 self.tr("Load regular expression"), |
364 "", |
363 "", |
365 self.tr("RegExp Files (*.rx);;All Files (*)")) |
364 self.tr("RegExp Files (*.rx);;All Files (*)")) |
366 if fname: |
365 if fname: |
|
366 fname = Utilities.toNativeSeparators(fname) |
367 try: |
367 try: |
368 f = open( |
368 with open(fname, "r", encoding="utf-8") as f: |
369 Utilities.toNativeSeparators(fname), "r", encoding="utf-8") |
369 regexp = f.read() |
370 regexp = f.read() |
|
371 f.close() |
|
372 self.regexpTextEdit.setPlainText(regexp) |
370 self.regexpTextEdit.setPlainText(regexp) |
373 except IOError as err: |
371 except IOError as err: |
374 E5MessageBox.information( |
372 E5MessageBox.information( |
375 self, |
373 self, |
376 self.tr("Save regular expression"), |
374 self.tr("Save regular expression"), |