Created
March 2, 2014 18:48
-
-
Save benfulton/9311549 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
# This script reads a GIT directory and prints out the contents | |
# appropriately to be incorporated into a Google Visualization Treemap | |
# https://code.google.com/apis/ajax/playground/?type=visualization#tree_map | |
import os | |
rootdir = "E:\\Git" | |
result = {} | |
for path, dirs, files in os.walk(rootdir): | |
key = os.path.basename(path) | |
if ".git" in path: | |
continue | |
parent = os.path.basename(os.path.dirname(path)) | |
count = len(files) | |
sm = sum(os.path.getsize(os.path.join(path, f)) for f in files) | |
if key not in result: | |
result[key] = (parent, count, sm) | |
print "['Location', 'Parent', 'File Count', 'File Size']," | |
for k,v in result.iteritems(): | |
print "['%s', '%s', %s, %s]," % (k, v[0], v[1], v[2]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment