Created
June 10, 2015 09:57
-
-
Save BjornFJohansson/f49aacf7cdc43a75c8f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# tree.py | |
# | |
# Written by Doug Dahms | |
# | |
# Prints the tree structure for the path specified on the command line | |
from os import listdir, sep | |
from os.path import abspath, basename, isdir | |
from sys import argv | |
def tree(dir, padding): | |
print padding[:-1] + basename(abspath(dir)) + '/' | |
padding = padding + ' ' | |
files = [] | |
files = [x for x in listdir(dir) if isdir(dir + sep + x)] | |
count = 0 | |
for file in files: | |
count += 1 | |
print padding + '|' | |
path = dir + sep + file | |
if isdir(path): | |
if count == len(files): | |
tree(path, padding + ' ') | |
else: | |
tree(path, padding + '|') | |
else: | |
print padding + '+-' + file | |
tree("/home/bjorn/Downloads", ' ') | |
''' | |
webpy-markdown | |
|- app.py | |
|- pages | |
| |- index.txt | |
| `- other.txt | |
`- templates | |
`- page.html | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment