Mercurial > hg > config
changeset 387:0aee0da6b06b
even more success
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 26 Jul 2013 16:20:22 -0700 |
parents | bea5f2fe4ea4 |
children | 3678770e8c52 |
files | python/tree2.py |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/python/tree2.py Fri Jul 26 14:58:18 2013 -0700 +++ b/python/tree2.py Fri Jul 26 16:20:22 2013 -0700 @@ -9,15 +9,19 @@ import os import sys -LINE = '|' +# ASCII delimeters +VERTICAL_LINE = '|' ITEM = '+' END = '\\' -# -LINE = '│' + +# unicode delimiters +VERTICAL_LINE = '│' ITEM = '├' END = '└' def depth(directory): + """returns the integer depth of a directory or path relative to '/' """ + directory = os.path.abspath(directory) level = 0 while True: @@ -49,12 +53,11 @@ dirpath_marker = ITEM if level > len(indent): - indent.append(LINE) + indent.append(VERTICAL_LINE) indent = indent[:level] if dirnames: files_end = ITEM - last[abspath] = dirnames[-1] else: files_end = END @@ -71,7 +74,7 @@ retval.append('%s%s%s'% (''.join(indent[:-1]), dirpath_mark, basename)) if filenames: last_file = filenames[-1] - retval.extend([('%s%s%s' % (str_indent, + retval.extend([('%s%s%s' % (''.join(indent), files_end if filename == last_file else ITEM, filename)) for index, filename in enumerate(filenames)])