Enable creating custom methods

This commit is contained in:
Bartłomiej Pluta
2019-07-08 17:48:02 +02:00
parent d8cdafe293
commit 6d56706354
7 changed files with 61 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ class Type(Enum):
LIST = (list, lambda x: f"[{', '.join([e.stringify() for e in x])}]")
PERCENT = (float, lambda x: f"{int(x * 100)}%")
NOTE = (Note, lambda x: x.note.name)
TYPE = (None, lambda x: str(x.type.name.lower()))
VOID = (type(None), lambda x: _failStringify(Type.VOID))
def stringify(self, element):

View File

@@ -5,7 +5,7 @@ class Value:
def __init__(self, objectType, value):
self.value = value
if type(value) == objectType.value[0]:
if objectType.value[0] is None or type(value) == objectType.value[0]:
self.type = objectType
elif type(value) == Value: