Created
June 4, 2014 09:39
-
-
Save vikingmute/058e6f683f1b7b51e972 to your computer and use it in GitHub Desktop.
get line numbers
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
import os,sys | |
dirname = sys.argv[1] | |
totalCount = 0; | |
cDir = os.getcwd() | |
#allowd file extsions, .js, .css ... | |
extDir = ['.js', '.less', '.tpl', '.html'] | |
#dir avoided to be checked | |
avoidDir = ['index/tpl', 'index/js'] | |
for root, dirs, files in os.walk(dirname): | |
suitDir = [ar for ar in avoidDir if root.find(ar) != -1] | |
if len(suitDir) > 0 : | |
continue | |
for f in files: | |
filename, fileExt = os.path.splitext(f) | |
if fileExt in extDir: | |
os.chdir(root) | |
ff = open(f, 'r') | |
lines = len(ff.readlines()) | |
totalCount += lines | |
os.chdir(cDir) | |
print 'filename: ' + f + ' lines:' + str(lines) + ' total:' + str(totalCount) + '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment