Created
March 12, 2010 17:29
-
-
Save emre/330550 to your computer and use it in GitHub Desktop.
code stats for a simple django project
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
# mirat'in kodu | |
# <proje>/scripts/stats.py | |
import glob | |
import os | |
SCAN_FOLDER = "../" | |
stats = { | |
"python" : 0, | |
"html" : 0, | |
"css" : 0, | |
} | |
def process_directory(foo,directory,files): | |
for file in files: | |
if os.path.splitext(file)[1] == ".py": | |
stats["python"] += len(open(os.path.join(directory,file),"r").readlines()) | |
if os.path.splitext(file)[1] == ".html": | |
stats["html"] += len(open(os.path.join(directory,file),"r").readlines()) | |
if os.path.splitext(file)[1] == ".css": | |
stats["css"] += len(open(os.path.join(directory,file),"r").readlines()) | |
os.path.walk(SCAN_FOLDER, process_directory, "foo") | |
total = 0 | |
for stat in stats.keys(): | |
total += stats[stat] | |
print "%s \t %s lines of code" % (stat, stats[stat]) | |
print "total \t %s lines of code" % total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment