-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsgf_parsing.py
29 lines (25 loc) · 901 Bytes
/
sgf_parsing.py
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
class SgfTree:
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 key, value in self.properties.items():
if key not in other.properties:
return False
if other.properties[key] != value:
return False
for key in other.properties.keys():
if key not in self.properties:
return False
if len(self.children) != len(other.children):
return False
for child, other_child in zip(self.children, other.children):
if child != other_child:
return False
return True
def __ne__(self, other):
return not self == other
def parse(input_string):
pass