Reformat evaluator #2 (exceptions)

This commit is contained in:
Bartłomiej Pluta
2019-07-04 18:09:20 +02:00
parent 34a0eda199
commit 23e0f3f33e
4 changed files with 23 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
from enum import Enum
from smnp.error.syntax import SyntaxException
from smnp.error.note import NoteException
class NotePitch(Enum):
@@ -37,18 +37,14 @@ class NotePitch(Enum):
return self.name
def __repr__(self):
return self.__str__()
#@staticmethod
#def checkInterval(a, b):
#return a.value - b.value
return self.__str__()
@staticmethod
def toPitch(string): #TODO: token zamiast stringa, żeby można było wziąć pos
def toPitch(string):
try:
return stringToPitch[string.lower()]
except KeyError as e:
raise SyntaxException(f"Note '{string}' does not exist") #TODO jakis inny exception
raise NoteException(f"Note '{string}' does not exist")
stringToPitch = {
'c': NotePitch.C,