-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.py
More file actions
30 lines (26 loc) · 839 Bytes
/
Copy pathvariable.py
File metadata and controls
30 lines (26 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from operator_box import Operator
class Variable():
def __init__(self,name,value="nil"):
self.hasvalue=False
self.value=value
self.name=name
if value!="nil":
self.hasvalue=True
self.connectedBox="nil"
def connectBox(self,box):
if self.connectedBox=="nil" and isinstance(box,Operator):
self.connectedBox=box
else:
raise ValueError
def hasValue(self):
if self.value=="nil":
self.hasvalue=False
else:
self.hasvalue=True
return self.hasvalue
def getValue(self):
if self.hasvalue:
return self.value
def work(self):
if not self.hasvalue and self.connectedBox.hasValue():
self.value=self.connectedBox.getValue()