Mercurial > hg > config
diff python/tree2.py @ 384:5ae5ada91ac8
simple numbering
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 26 Jul 2013 09:45:46 -0700 |
parents | 8d1ad56761b0 |
children | 6ef0ea2f10e3 |
line wrap: on
line diff
--- a/python/tree2.py Fri Jul 26 05:56:18 2013 -0700 +++ b/python/tree2.py Fri Jul 26 09:45:46 2013 -0700 @@ -23,14 +23,16 @@ def tree(directory): - sort_key=lambda x: x.lower()) + sort_key=lambda x: x.lower() retval = [directory] top = depth(directory) indent = [] + last = {} for dirpath, dirnames, filenames in os.walk(directory, topdown=True): abspath = os.path.abspath(dirpath) - parent = os.path.dirname(abspath)) + basename = os.path.basename(abspath) + parent = os.path.dirname(abspath) level = depth(abspath) - top # sort articles of interest @@ -43,6 +45,11 @@ if last.get(parent) == os.path.basename(abspath): pass + retval.append('%s%s'% (str(level) * level, basename)) + level += 1 + retval.extend([('%s%s' % (str(level) * level, filename)) + for filename in filenames]) + # retval.append('%s%s%s %s' % ('│' * (indent-1), # ('├' if basename == basename else '└') if indent else '', # basename))