Added support to state for type nodes

This commit is contained in:
Andrei Bondarenko 2021-07-13 05:08:31 +02:00
parent b961e91d9b
commit 128b3ec1e4

View file

@ -1,8 +1,9 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Any, List, Tuple, TypeVar, Optional, Union, Generator from typing import Any, List, Tuple, Optional, Union
import uuid import uuid
primitive_types = (int, float, str, bool) primitive_types = (int, float, str, bool)
type_values = ("Integer", "Float", "String", "Boolean", "Type")
Node = str Node = str
@ -36,6 +37,8 @@ class State(ABC):
Returns: Returns:
True if value type is supported, False otherwise. True if value type is supported, False otherwise.
""" """
if isinstance(value, dict) and value.get("type", None) in type_values:
return True
if not isinstance(value, primitive_types): if not isinstance(value, primitive_types):
return False return False
elif isinstance(value, int) and not (-2**63 <= value <= 2**63 - 1): elif isinstance(value, int) and not (-2**63 <= value <= 2**63 - 1):
@ -100,8 +103,7 @@ class State(ABC):
target: target element of edge target: target element of edge
Returns: Returns:
Tuple containing the created edges and label node, None is source or target don't exist Nothing.
or value type doesn't exist. First edge goes from source to target, second from edge to label.
""" """
pass pass