2019-11-07 08:58:16 -05:00
|
|
|
class SgfTree:
|
2018-04-03 09:55:43 -04:00
|
|
|
def __init__(self, properties=None, children=None):
|
|
|
|
|
self.properties = properties or {}
|
|
|
|
|
self.children = children or []
|
|
|
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
|
if not isinstance(other, SgfTree):
|
|
|
|
|
return False
|
|
|
|
|
for k, v in self.properties.items():
|
|
|
|
|
if k not in other.properties:
|
|
|
|
|
return False
|
|
|
|
|
if other.properties[k] != v:
|
|
|
|
|
return False
|
|
|
|
|
for k in other.properties.keys():
|
|
|
|
|
if k not in self.properties:
|
|
|
|
|
return False
|
|
|
|
|
if len(self.children) != len(other.children):
|
|
|
|
|
return False
|
|
|
|
|
for a, b in zip(self.children, other.children):
|
|
|
|
|
if a != b:
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
2018-12-10 15:30:17 +02:00
|
|
|
def __ne__(self, other):
|
|
|
|
|
return not self == other
|
|
|
|
|
|
2018-04-03 09:55:43 -04:00
|
|
|
|
|
|
|
|
def parse(input_string):
|
|
|
|
|
pass
|