diff --git a/redbaron.py b/redbaron.py index 1fcd9dfb..138dc416 100644 --- a/redbaron.py +++ b/redbaron.py @@ -71,6 +71,14 @@ def set_node(self, node): self.path = baron.path.make_path(path, parent_node_type, render_pos) + def __eq__(self, other): + return not self != other + + def __ne__(self, other): + if not isinstance(other, Path): + return True + return self.path != other.path + @classmethod def from_baron_path(class_, node, path): if baron.path.is_empty(path): @@ -586,6 +594,15 @@ def __repr__(self): else: return self.dumps() + def __eq__(self, other): + return not self != other + + def __ne__(self, other): + for key in itertools.chain(self._str_keys, self._list_keys, self._dict_keys): + if getattr(self, key) != getattr(other, key, None): + return True + return False + def copy(self): # XXX not very optimised but at least very simple return to_node(self.fst())