changeset 425:5417eb6364ee

stubbing
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 06 Aug 2013 18:26:42 -0700
parents d214e0f38ab1
children 866c5b1bc4e8
files python/tree.py
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/python/tree.py	Tue Aug 06 16:04:28 2013 -0700
+++ b/python/tree.py	Tue Aug 06 18:26:42 2013 -0700
@@ -5,6 +5,8 @@
 tree in python
 """
 
+# TODO: script2package
+
 import optparse
 import os
 import sys
@@ -23,6 +25,7 @@
     'last_child'    : '└'
     }
 
+
 def depth(directory):
     """returns the integer depth of a directory or path relative to '/' """
 
@@ -35,6 +38,36 @@
             break
     return level
 
+
+### stuff for tree generalization
+
+class Tree(object):
+    """tree structure in python"""
+
+    def __init__(self, parent=None):
+        self.parent = parent
+
+    def children(self):
+        """returns children of the tree"""
+
+    def add(self, item):
+        """add a child to the tree root"""
+
+    def update(self, tree):
+        """add a subtree to the tree"""
+        self.add(tree)
+        tree.parent = self # XXX .add should probably do this for scary reasons
+
+    def output(self, serializer):
+        """output the tree via the given serializer"""
+        # XXX or should this method exist at all and instead the
+        # __call__ method of serializers take a Tree object?
+
+class DirectoryTree(Tree):
+    """directory structure as a tree"""
+
+###
+
 def tree(directory,
          item_marker=unicode_delimeters['item_marker'],
          vertical_line=unicode_delimeters['vertical_line'],