-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathLineCounter.py
More file actions
42 lines (38 loc) · 971 Bytes
/
LineCounter.py
File metadata and controls
42 lines (38 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import os
EXTS = set([
'cc', 'cpp', 'c', 'cxx',
'java',
'js',
'py',
'php',
'hs',
'scala', 'scl',
'erl',
'cs',
'sh',
'go',
'fs',
'sql',
'swift'])
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('Exemplars' not in root
and 'utils' not in root
and 'Note' not in root
and item.split('.')[-1] in EXTS)
]
)
code_lines += sum(code_list)
code_files += len(code_list)
print "Total problems solved :", code_files
print "Total lines of your code :", code_lines