Check instance once

This commit is contained in:
Salvo 'LtWorf' Tomaselli 2020-06-27 15:47:55 +02:00
parent 79610ab8f5
commit 9f171fa393
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF

View File

@ -147,14 +147,18 @@ class Node:
if isinstance(self, Variable): #FIXME this is ugly
return list(rels[self.name].header)
elif isinstance(self, Binary) and self.name in (DIFFERENCE, UNION, INTERSECTION):
elif isinstance(self, Binary):
if self.name in (DIFFERENCE, UNION, INTERSECTION):
return self.left.result_format(rels)
elif isinstance(self, Binary) and self.name == DIVISION:
elif self.name == DIVISION:
return list(set(self.left.result_format(rels)) - set(self.right.result_format(rels)))
elif self.name == PROJECTION:
return self.get_projection_prop()
elif self.name == PRODUCT:
return self.left.result_format(rels) + self.right.result_format(rels)
elif self.name in (JOIN, JOIN_LEFT, JOIN_RIGHT, JOIN_FULL):
return list(set(self.left.result_format(rels)).union(set(self.right.result_format(rels))))
elif isinstance(self, Unary):
if self.name == PROJECTION:
return self.get_projection_prop()
elif self.name == SELECTION:
return self.child.result_format(rels)
elif self.name == RENAME:
@ -168,8 +172,7 @@ class Node:
if _fields[i] in _vars:
_fields[i] = _vars[_fields[i]]
return _fields
elif self.name in (JOIN, JOIN_LEFT, JOIN_RIGHT, JOIN_FULL):
return list(set(self.left.result_format(rels)).union(set(self.right.result_format(rels))))
raise ValueError('What kind of alien object is this?')
def __eq__(self, other): #FIXME