diff --git a/PyFlow/Input.py b/PyFlow/Input.py index b63713e0..58cabfb8 100644 --- a/PyFlow/Input.py +++ b/PyFlow/Input.py @@ -13,10 +13,10 @@ ## limitations under the License. -from collections import Counter from collections import defaultdict +from enum import Enum -from Qt import QtCore, QtGui +from qtpy import QtCore, QtGui from PyFlow.Core.Common import * @@ -27,16 +27,26 @@ class InputActionType(Enum): class InputAction(object): - def __init__(self, name="defaultName", actionType=InputActionType.Keyboard, group="default", mouse=QtCore.Qt.NoButton, key=None, modifiers=QtCore.Qt.NoModifier): + def __init__( + self, + name="defaultName", + actionType=InputActionType.Keyboard, + group="default", + mouse=QtCore.Qt.NoButton, + key=None, + modifiers=QtCore.Qt.NoModifier, + ): self.__actionType = actionType self._name = name self._group = group self.__data = {"mouse": mouse, "key": key, "modifiers": modifiers} def __str__(self): - return "{0} {1} {2}".format(QtGui.QKeySequence(self.getModifiers()).toString(), - self.getMouseButton().name.decode('utf=8'), - QtGui.QKeySequence(self.getKey()).toString()) + return "{0} {1} {2}".format( + QtGui.QKeySequence(self.getModifiers()).toString(), + self.getMouseButton().name.decode("utf=8"), + QtGui.QKeySequence(self.getKey()).toString(), + ) @property def group(self): @@ -53,10 +63,7 @@ def __eq__(self, other): om = other.getData()["mouse"] ok = other.getData()["key"] omod = other.getData()["modifiers"] - smod == omod - return all([sm == om, - sk == ok, - smod == omod]) + return all([sm == om, sk == ok, smod == omod]) def __ne__(self, other): sm = self.__data["mouse"] @@ -65,9 +72,7 @@ def __ne__(self, other): om = other.getData()["mouse"] ok = other.getData()["key"] omod = other.getData()["modifiers"] - return not all([sm == om, - sk == ok, - smod == omod]) + return not all([sm == om, sk == ok, smod == omod]) def getName(self): return self._name @@ -76,14 +81,16 @@ def getData(self): return self.__data def setMouseButton(self, btn): - assert(isinstance(btn, QtCore.Qt.MouseButton)) + assert isinstance(btn, QtCore.Qt.MouseButton) self.__data["mouse"] = btn def getMouseButton(self): return self.__data["mouse"] - def setKey(self, key=[]): - assert(isinstance(key, QtCore.Qt.Key)) + def setKey(self, key=None): + if key is None: + key = [] + assert isinstance(key, QtCore.Qt.Key) self.__data["key"] = key def getKey(self): @@ -112,24 +119,24 @@ def _modifiersToList(mods): result.append(QtCore.Qt.GroupSwitchModifier) return result - def _listOfModifiersToEnum(self, modifiersList): + @staticmethod + def _listOfModifiersToEnum(modifiersList): result = QtCore.Qt.NoModifier for mod in modifiersList: result = result | mod return result def toJson(self): - saveData = {} - saveData["name"] = self._name - saveData["group"] = self._group - saveData["mouse"] = int(self.__data["mouse"]) - saveData["actionType"] = self.actionType.value - + saveData = {"name": self._name, + "group": self._group, + "mouse": int(self.__data["mouse"].value), + "actionType": self.actionType.value} key = self.__data["key"] saveData["key"] = int(key) if key is not None else None modifiersList = self._modifiersToList(self.__data["modifiers"]) - saveData["modifiers"] = [int(i) for i in modifiersList] + + saveData["modifiers"] = [i.value for i in modifiersList] return saveData def fromJson(self, jsonData): @@ -138,8 +145,12 @@ def fromJson(self, jsonData): self._group = jsonData["group"] self.__data["mouse"] = QtCore.Qt.MouseButton(jsonData["mouse"]) keyJson = jsonData["key"] - self.__data["key"] = QtCore.Qt.Key(keyJson) if isinstance(keyJson, int) else None - self.__data["modifiers"] = self._listOfModifiersToEnum([QtCore.Qt.KeyboardModifier(i) for i in jsonData["modifiers"]]) + self.__data["key"] = ( + QtCore.Qt.Key(keyJson) if isinstance(keyJson, int) else None + ) + self.__data["modifiers"] = self._listOfModifiersToEnum( + [QtCore.Qt.KeyboardModifier(i) for i in jsonData["modifiers"]] + ) self.__actionType = InputActionType(jsonData["actionType"]) return self except: diff --git a/hooks/post-checkout b/hooks/post-checkout new file mode 100644 index 00000000..cab40f26 --- /dev/null +++ b/hooks/post-checkout @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout.\n"; exit 2; } +git lfs post-checkout "$@" diff --git a/hooks/post-commit b/hooks/post-commit new file mode 100644 index 00000000..9443f416 --- /dev/null +++ b/hooks/post-commit @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-commit.\n"; exit 2; } +git lfs post-commit "$@" diff --git a/hooks/post-merge b/hooks/post-merge new file mode 100644 index 00000000..828b7089 --- /dev/null +++ b/hooks/post-merge @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-merge.\n"; exit 2; } +git lfs post-merge "$@" diff --git a/hooks/pre-push b/hooks/pre-push new file mode 100644 index 00000000..81a9cc63 --- /dev/null +++ b/hooks/pre-push @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; } +git lfs pre-push "$@" diff --git a/lfs/objects/76/37/763734832a0c331aa849283545b619a739bf2787568a3a4dae3a9fd57377b401 b/lfs/objects/76/37/763734832a0c331aa849283545b619a739bf2787568a3a4dae3a9fd57377b401 new file mode 100644 index 00000000..8ad42237 Binary files /dev/null and b/lfs/objects/76/37/763734832a0c331aa849283545b619a739bf2787568a3a4dae3a9fd57377b401 differ