diff -r f95dde35d0ab -r 0090cfa83159 eric6/HexEdit/HexEditUndoStack.py --- a/eric6/HexEdit/HexEditUndoStack.py Mon Apr 26 17:33:08 2021 +0200 +++ b/eric6/HexEdit/HexEditUndoStack.py Tue Apr 27 17:25:06 2021 +0200 @@ -7,18 +7,18 @@ Module implementing the Undo stack for the hex edit widget. """ -from enum import Enum +import enum from PyQt5.QtWidgets import QUndoStack, QUndoCommand -class HexEditCommand(Enum): +class HexEditCommand(enum.Enum): """ - Class implementing the edit comands. + Class implementing the edit commands. """ - Insert = 0 - RemoveAt = 1 - Overwrite = 2 + INSERT = 0 + REMOVEAT = 1 + OVERWRITE = 2 class HexEditUndoCommand(QUndoCommand): @@ -54,12 +54,12 @@ """ Public method to undo the command. """ - if self._cmd == HexEditCommand.Insert: + if self._cmd == HexEditCommand.INSERT: self.__chunks.removeAt(self._pos) - elif self._cmd == HexEditCommand.Overwrite: + elif self._cmd == HexEditCommand.OVERWRITE: self.__chunks.overwrite(self._pos, self.__oldByte) self.__chunks.setDataChanged(self._pos, self.__wasChanged) - elif self._cmd == HexEditCommand.RemoveAt: + elif self._cmd == HexEditCommand.REMOVEAT: self.__chunks.insert(self._pos, self.__oldByte) self.__chunks.setDataChanged(self._pos, self.__wasChanged) @@ -67,13 +67,13 @@ """ Public method to redo the command. """ - if self._cmd == HexEditCommand.Insert: + if self._cmd == HexEditCommand.INSERT: self.__chunks.insert(self._pos, self._newByte) - elif self._cmd == HexEditCommand.Overwrite: + elif self._cmd == HexEditCommand.OVERWRITE: self.__oldByte = self.__chunks[self._pos] self.__wasChanged = self.__chunks.dataChanged(self._pos) self.__chunks.overwrite(self._pos, self._newByte) - elif self._cmd == HexEditCommand.RemoveAt: + elif self._cmd == HexEditCommand.REMOVEAT: self.__oldByte = self.__chunks[self._pos] self.__wasChanged = self.__chunks.dataChanged(self._pos) self.__chunks.removeAt(self._pos) @@ -90,8 +90,8 @@ result = False if ( - self._cmd != HexEditCommand.RemoveAt and - command._cmd == HexEditCommand.Overwrite and + self._cmd != HexEditCommand.REMOVEAT and + command._cmd == HexEditCommand.OVERWRITE and command._pos == self._pos ): self._newByte = command._newByte @@ -138,7 +138,7 @@ """ if pos >= 0 and pos <= self.__chunks.size(): uc = HexEditUndoCommand( - self.__chunks, HexEditCommand.Insert, pos, data) + self.__chunks, HexEditCommand.INSERT, pos, data) self.push(uc) def insertByteArray(self, pos, byteArray): @@ -157,7 +157,7 @@ self.beginMacro(txt) for idx in range(len(ba)): uc = HexEditUndoCommand( - self.__chunks, HexEditCommand.Insert, pos + idx, ba[idx]) + self.__chunks, HexEditCommand.INSERT, pos + idx, ba[idx]) self.push(uc) self.endMacro() @@ -173,14 +173,14 @@ if pos >= 0 and pos <= self.__chunks.size(): if length == 1: uc = HexEditUndoCommand( - self.__chunks, HexEditCommand.RemoveAt, pos, 0) + self.__chunks, HexEditCommand.REMOVEAT, pos, 0) self.push(uc) else: txt = self.tr("Deleting %n byte(s)", "", length) self.beginMacro(txt) for _cnt in range(length): uc = HexEditUndoCommand( - self.__chunks, HexEditCommand.RemoveAt, pos, 0) + self.__chunks, HexEditCommand.REMOVEAT, pos, 0) self.push(uc) self.endMacro() @@ -195,7 +195,7 @@ """ if pos >= 0 and pos <= self.__chunks.size(): uc = HexEditUndoCommand( - self.__chunks, HexEditCommand.Overwrite, pos, data) + self.__chunks, HexEditCommand.OVERWRITE, pos, data) self.push(uc) def overwriteByteArray(self, pos, length, byteArray):