Skip to content

Instantly share code, notes, and snippets.

@Wizmann
Created November 23, 2012 14:28
Show Gist options
  • Save Wizmann/4135855 to your computer and use it in GitHub Desktop.
Save Wizmann/4135855 to your computer and use it in GitHub Desktop.
PyMrLineCounter.py
#!/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