aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util/tree.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/util/tree.py')
-rw-r--r--libbe/util/tree.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/libbe/util/tree.py b/libbe/util/tree.py
index c6aa46b..5d0da49 100644
--- a/libbe/util/tree.py
+++ b/libbe/util/tree.py
@@ -22,9 +22,10 @@
"""
import libbe
-if libbe.TESTING == True:
+if libbe.TESTING:
import doctest
+
class Tree(list):
"""A traversable tree structure.
@@ -115,7 +116,7 @@ class Tree(list):
True
"""
def __cmp__(self, other):
- return cmp(id(self), id(other))
+ return (id(self) > id(other)) - (id(self) < id(other))
def __eq__(self, other):
return self.__cmp__(other) == 0
@@ -172,7 +173,7 @@ class Tree(list):
in the order they are stored, so you might want to
:py:meth:`sort` your tree first.
"""
- if depth_first == True:
+ if depth_first:
yield self
for child in self:
for descendant in child.traverse():
@@ -213,7 +214,7 @@ class Tree(list):
"""
stack = [] # ancestry of the current node
- if flatten == True:
+ if flatten:
depthDict = {}
for node in self.traverse(depth_first=True):
@@ -256,5 +257,5 @@ class Tree(list):
return True
return False
-if libbe.TESTING == True:
+if libbe.TESTING:
suite = doctest.DocTestSuite()