Skip to content

Commit

Permalink
code count
Browse files Browse the repository at this point in the history
  • Loading branch information
laowan committed Apr 28, 2014
1 parent 72f3961 commit 479afc7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions code_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

def code_count(path):
print path
file_count = 0
line_count = 0

for root, dirs, files in os.walk(path):
for file in files:
ext = file[file.find('.'):]
if ext in ['.cpp', '.c', '.hpp', '.h']:
file_count += 1
file_path = root + '\\' + file
fp = open(file_path)
line_count += len(fp.readlines())
fp.close()

print file_count
print line_count
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from code_count import code_count

source_path = './data/'
database = {}
Expand Down Expand Up @@ -58,4 +59,5 @@ def parse_file(filename):
if os.path.isfile(filename):
parse_file(filename)

print database
#print database
code_count(source_path)

0 comments on commit 479afc7

Please sign in to comment.