Created
November 23, 2012 14:28
-
-
Save Wizmann/4135855 to your computer and use it in GitHub Desktop.
PyMrLineCounter.py
This file contains hidden or 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 | |
# -*- encoding: utf-8 -*- | |
import sys,os | |
EXTS = set(['cc', 'java', 'cpp', 'c', 'py', 'cxx', 'hs', 'scala', 'scl']) | |
def LineCounter(i_path): | |
with open(i_path) as code_file: | |
return code_file.read().count('\n') | |
if(__name__=='__main__'): | |
code_lines,code_files=0,0 | |
for root, dirs, files in os.walk(sys.path[0]): | |
code_list=map(LineCounter,[os.path.join(root,item)\ | |
for item in files \ | |
if('模版' not in root and item.split('.')[-1] in EXTS)]) | |
if(code_list): | |
code_lines+=reduce(lambda x,y:x+y,code_list) | |
code_files+=len(code_list) | |
print "Total problem sloved :",code_files | |
print "Total lines of your code :",code_lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment