# -*- coding: utf-8 -*-#!/usr/bin/python# linecount.py# 2009-1-20# author:# Jason Lee#importsysimportosexts=['.cs','.aspx','.cs','.js','.css','.ashx','.master','.ascx','.svc','.config']defread_line_count(fname):count=0forfile_lineinopen(fname).xreadlines():count+=1returncountif__name__=='__main__':count=0fcount=0forroot,dirs,filesinos.walk(os.getcwd()):forfinfiles:# Check the sub directorysfname=(root+'/'+f).lower()ext=f[f.rindex('.'):]try:if(exts.index(ext)>=0):fcount+=1c=read_line_count(fname)count+=cexcept:passprint'file count:%d'%fcountprint'count:%d'%count