comparison python/tree.py @ 429:9b7f5e31b465

python/tree.py
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 07 Aug 2013 06:33:16 -0700
parents 866c5b1bc4e8
children fbb5b143349a
comparison
equal deleted inserted replaced
428:59e6c8115a97 429:9b7f5e31b465
65 # XXX or should this method exist at all and instead the 65 # XXX or should this method exist at all and instead the
66 # __call__ method of serializers take a Tree object? 66 # __call__ method of serializers take a Tree object?
67 67
68 class DirectoryTree(Tree): 68 class DirectoryTree(Tree):
69 """directory structure as a tree""" 69 """directory structure as a tree"""
70
71 def __init__(self, directory):
72 self.directory = directory
73 self._return_type = os.path.abspath
74
75 def children(self):
76 return os.listdir(self.directory) # -> self._return_type
77
78 ## Serializers
79
80 # How to serialize a tree -> JSON?
70 81
71 ### 82 ###
72 83
73 def tree(directory, 84 def tree(directory,
74 item_marker=unicode_delimeters['item_marker'], 85 item_marker=unicode_delimeters['item_marker'],