Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxboron committed Jan 15, 2013
1 parent 8c83e5d commit 32913da
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions tests/treesample.py
Expand Up @@ -40,7 +40,7 @@
class ExampleTreeWidget(urwid.TreeWidget):
""" Display widget for leaf nodes """
def get_display_text(self):
return self.get_node().get_value()["name"]
return self.get_node().get_value()['name']


class ExampleNode(urwid.TreeNode):
Expand All @@ -66,9 +66,6 @@ def load_child_node(self, key):
childclass = ExampleParentNode
else:
childclass = ExampleNode
print(self)
print(key)
print(childdepth)
return childclass(childdata, parent=self, key=key, depth=childdepth)


Expand Down Expand Up @@ -125,21 +122,18 @@ def get_example_tree():
""" generate a quick 100 leaf tree for demo purposes """
f = open("comments.data", "r").read()
info = json.loads(f)[0]
s = "%s %s\n%s" % (info["username"], info["time"], info["comment"])
retval = {"name":s,"children":[]}
pprint(info)
s = "%s %s\n%s\n" % (info["username"], info["time"], info["comment"])
retval = {"name":s, "children": []}
for i in range(len(info["children"])):
l = get_example_tree_recursion(info["children"][i],i=i)
l = get_example_tree_recursion(info["children"][i])
retval["children"].append(l)
return retval

def get_example_tree_recursion(info,i=None):
s = "%s %s\n%s" % (info["username"], info["time"], info["comment"])
n = {"name": s}
if info.get("children"):
n["children"]=[]
def get_example_tree_recursion(info):
s = "%s %s\n%s\n" % (info["username"], info["time"], info["comment"])
n = {"name": s, "children": []}
for j in range(len(info["children"])):
l = get_example_tree_recursion(info["children"][j],i=j)
l = get_example_tree_recursion(info["children"][j])
n["children"].append(l)
return n

Expand Down

0 comments on commit 32913da

Please sign in to comment.