Files
wren/metrics

40 lines
740 B
Plaintext
Raw Normal View History

2013-10-31 21:54:04 -07:00
#!/usr/bin/python
import glob
import re
2013-11-05 07:57:18 -08:00
TODO_PATTERN = re.compile(r'\s*// TODO\(')
DOC_PATTERN = re.compile(r'\s*//')
2013-10-31 21:54:04 -07:00
num_files = 0
2013-11-05 07:57:18 -08:00
num_docs = 0
num_code = 0
num_empty = 0
2013-10-31 21:54:04 -07:00
num_todos = 0
for source_path in glob.iglob("src/*.[ch]"):
num_files += 1
with open(source_path, "r") as input:
for line in input:
2013-11-05 07:57:18 -08:00
match = TODO_PATTERN.match(line)
2013-10-31 21:54:04 -07:00
if match:
num_todos += 1
2013-11-05 07:57:18 -08:00
continue
match = DOC_PATTERN.match(line)
if match:
num_docs += 1
continue
if (line.strip() == ""):
num_empty += 1
continue
num_code += 1
2013-10-31 21:54:04 -07:00
2013-11-05 07:57:18 -08:00
print num_files, "files"
print num_todos, "TODOs"
print num_docs, "comment lines"
print num_code, "code lines"
print num_empty, "empty lines"