Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions redbaron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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())
Expand Down