1076 if exporterFormat: |
1076 if exporterFormat: |
1077 exporter = Exporters.getExporter(exporterFormat, self) |
1077 exporter = Exporters.getExporter(exporterFormat, self) |
1078 if exporter: |
1078 if exporter: |
1079 exporter.exportSource() |
1079 exporter.exportSource() |
1080 else: |
1080 else: |
1081 QMessageBox.critical(self, |
1081 E5MessageBox.critical(self, |
1082 self.trUtf8("Export source"), |
1082 self.trUtf8("Export source"), |
1083 self.trUtf8("""<p>No exporter available for the """ |
1083 self.trUtf8("""<p>No exporter available for the """ |
1084 """export format <b>{0}</b>. Aborting...</p>""")\ |
1084 """export format <b>{0}</b>. Aborting...</p>""")\ |
1085 .format(exporterFormat)) |
1085 .format(exporterFormat)) |
1086 else: |
1086 else: |
1087 QMessageBox.critical(self, |
1087 E5MessageBox.critical(self, |
1088 self.trUtf8("Export source"), |
1088 self.trUtf8("Export source"), |
1089 self.trUtf8("""No export format given. Aborting...""")) |
1089 self.trUtf8("""No export format given. Aborting...""")) |
1090 |
1090 |
1091 def __showContextMenuLanguages(self): |
1091 def __showContextMenuLanguages(self): |
1092 """ |
1092 """ |
2233 f = open(fn, "w") |
2233 f = open(fn, "w") |
2234 f.close() |
2234 f.close() |
2235 txt, self.encoding = Utilities.readEncodedFile(fn) |
2235 txt, self.encoding = Utilities.readEncodedFile(fn) |
2236 except (UnicodeDecodeError, IOError) as why: |
2236 except (UnicodeDecodeError, IOError) as why: |
2237 QApplication.restoreOverrideCursor() |
2237 QApplication.restoreOverrideCursor() |
2238 QMessageBox.critical(self.vm, self.trUtf8('Open File'), |
2238 E5MessageBox.critical(self.vm, self.trUtf8('Open File'), |
2239 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>' |
2239 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>' |
2240 '<p>Reason: {1}</p>') |
2240 '<p>Reason: {1}</p>') |
2241 .format(fn, str(why))) |
2241 .format(fn, str(why))) |
2242 QApplication.restoreOverrideCursor() |
2242 QApplication.restoreOverrideCursor() |
2243 raise |
2243 raise |
2331 self.encoding = Utilities.writeEncodedFile(fn, txt, self.encoding) |
2331 self.encoding = Utilities.writeEncodedFile(fn, txt, self.encoding) |
2332 if createBackup and perms_valid: |
2332 if createBackup and perms_valid: |
2333 os.chmod(fn, permissions) |
2333 os.chmod(fn, permissions) |
2334 return True |
2334 return True |
2335 except (IOError, Utilities.CodingError, UnicodeError) as why: |
2335 except (IOError, Utilities.CodingError, UnicodeError) as why: |
2336 QMessageBox.critical(self, self.trUtf8('Save File'), |
2336 E5MessageBox.critical(self, self.trUtf8('Save File'), |
2337 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>' |
2337 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>' |
2338 'Reason: {1}</p>') |
2338 'Reason: {1}</p>') |
2339 .format(fn, str(why))) |
2339 .format(fn, str(why))) |
2340 return False |
2340 return False |
2341 |
2341 |
4415 if line == -1: |
4415 if line == -1: |
4416 line = self.line |
4416 line = self.line |
4417 |
4417 |
4418 for handle in list(self.syntaxerrors.keys()): |
4418 for handle in list(self.syntaxerrors.keys()): |
4419 if self.markerLine(handle) == line: |
4419 if self.markerLine(handle) == line: |
4420 QMessageBox.critical(None, |
4420 E5MessageBox.critical(self, |
4421 self.trUtf8("Syntax Error"), |
4421 self.trUtf8("Syntax Error"), |
4422 self.syntaxerrors[handle]) |
4422 self.syntaxerrors[handle]) |
4423 break |
4423 break |
4424 else: |
4424 else: |
4425 QMessageBox.critical(None, |
4425 E5MessageBox.critical(self, |
4426 self.trUtf8("Syntax Error"), |
4426 self.trUtf8("Syntax Error"), |
4427 self.trUtf8("No syntax error message available.")) |
4427 self.trUtf8("No syntax error message available.")) |
4428 |
4428 |
4429 ############################################################################ |
4429 ############################################################################ |
4430 ## Flakes warning handling methods below |
4430 ## Flakes warning handling methods below |
4601 try: |
4601 try: |
4602 f = open(fname, "r", encoding = "utf-8") |
4602 f = open(fname, "r", encoding = "utf-8") |
4603 lines = f.readlines() |
4603 lines = f.readlines() |
4604 f.close() |
4604 f.close() |
4605 except IOError: |
4605 except IOError: |
4606 QMessageBox.critical(self, |
4606 E5MessageBox.critical(self, |
4607 self.trUtf8("Error loading macro"), |
4607 self.trUtf8("Error loading macro"), |
4608 self.trUtf8("<p>The macro file <b>{0}</b> could not be read.</p>") |
4608 self.trUtf8("<p>The macro file <b>{0}</b> could not be read.</p>") |
4609 .format(fname)) |
4609 .format(fname)) |
4610 return |
4610 return |
4611 |
4611 |
4612 if len(lines) != 2: |
4612 if len(lines) != 2: |
4613 QMessageBox.critical(self, |
4613 E5MessageBox.critical(self, |
4614 self.trUtf8("Error loading macro"), |
4614 self.trUtf8("Error loading macro"), |
4615 self.trUtf8("<p>The macro file <b>{0}</b> is corrupt.</p>") |
4615 self.trUtf8("<p>The macro file <b>{0}</b> is corrupt.</p>") |
4616 .format(fname)) |
4616 .format(fname)) |
4617 return |
4617 return |
4618 |
4618 |
4662 f = open(fname, "w", encoding = "utf-8") |
4662 f = open(fname, "w", encoding = "utf-8") |
4663 f.write("{0}{1}".format(name, "\n")) |
4663 f.write("{0}{1}".format(name, "\n")) |
4664 f.write(self.macros[name].save()) |
4664 f.write(self.macros[name].save()) |
4665 f.close() |
4665 f.close() |
4666 except IOError: |
4666 except IOError: |
4667 QMessageBox.critical(self, |
4667 E5MessageBox.critical(self, |
4668 self.trUtf8("Error saving macro"), |
4668 self.trUtf8("Error saving macro"), |
4669 self.trUtf8("<p>The macro file <b>{0}</b> could not be written.</p>") |
4669 self.trUtf8("<p>The macro file <b>{0}</b> could not be written.</p>") |
4670 .format(fname)) |
4670 .format(fname)) |
4671 return |
4671 return |
4672 |
4672 |