9 |
9 |
10 import os |
10 import os |
11 import contextlib |
11 import contextlib |
12 |
12 |
13 from PyQt6.QtCore import ( |
13 from PyQt6.QtCore import ( |
14 pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, QCoreApplication, QLocale |
14 pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, QCoreApplication, QLocale, |
|
15 QIODevice |
15 ) |
16 ) |
16 from PyQt6.QtGui import QKeySequence, QAction |
17 from PyQt6.QtGui import QKeySequence, QAction |
17 from PyQt6.QtWidgets import ( |
18 from PyQt6.QtWidgets import ( |
18 QWhatsThis, QLabel, QWidget, QVBoxLayout, QDialog, QFrame, QMenu |
19 QWhatsThis, QLabel, QWidget, QVBoxLayout, QDialog, QFrame, QMenu |
19 ) |
20 ) |
989 self, self.tr("eric Hex Editor"), |
990 self, self.tr("eric Hex Editor"), |
990 self.tr("The file '{0}' does not exist.") |
991 self.tr("The file '{0}' does not exist.") |
991 .format(fileName)) |
992 .format(fileName)) |
992 return |
993 return |
993 |
994 |
994 if not file.open(QFile.ReadOnly): |
995 if not file.open(QIODevice.OpenModeFlag.ReadOnly): |
995 EricMessageBox.warning( |
996 EricMessageBox.warning( |
996 self, self.tr("eric Hex Editor"), |
997 self, self.tr("eric Hex Editor"), |
997 self.tr("Cannot read file '{0}:\n{1}.") |
998 self.tr("Cannot read file '{0}:\n{1}.") |
998 .format(fileName, file.errorString())) |
999 .format(fileName, file.errorString())) |
999 return |
1000 return |
1103 @type str |
1104 @type str |
1104 @return flag indicating success |
1105 @return flag indicating success |
1105 @rtype bool |
1106 @rtype bool |
1106 """ |
1107 """ |
1107 file = QFile(fileName) |
1108 file = QFile(fileName) |
1108 if not file.open(QFile.WriteOnly): |
1109 if not file.open(QIODevice.OpenModeFlag.WriteOnly): |
1109 EricMessageBox.warning( |
1110 EricMessageBox.warning( |
1110 self, self.tr("eric Hex Editor"), |
1111 self, self.tr("eric Hex Editor"), |
1111 self.tr("Cannot write file '{0}:\n{1}.") |
1112 self.tr("Cannot write file '{0}:\n{1}.") |
1112 .format(fileName, file.errorString())) |
1113 .format(fileName, file.errorString())) |
1113 |
1114 |
1178 icon=EricMessageBox.Warning) |
1179 icon=EricMessageBox.Warning) |
1179 if not res: |
1180 if not res: |
1180 return |
1181 return |
1181 |
1182 |
1182 file = QFile(fileName) |
1183 file = QFile(fileName) |
1183 if not file.open(QFile.WriteOnly): |
1184 if not file.open(QIODevice.OpenModeFlag.WriteOnly): |
1184 EricMessageBox.warning( |
1185 EricMessageBox.warning( |
1185 self, self.tr("eric Hex Editor"), |
1186 self, self.tr("eric Hex Editor"), |
1186 self.tr("Cannot write file '{0}:\n{1}.") |
1187 self.tr("Cannot write file '{0}:\n{1}.") |
1187 .format(fileName, file.errorString())) |
1188 .format(fileName, file.errorString())) |
1188 return |
1189 return |