-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataCounter.py
44 lines (40 loc) · 1.57 KB
/
dataCounter.py
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
43
44
import subprocess
import sys
rcmd = "( find ./ -type d -name .git -prune -o -name '*.%s' -print0 | xargs -0 cat ) | wc {}"
types = ['c', 'cpp', 'h', 'hpp', 'py', 'para', 'paracode', 'sh']
if len(sys.argv) > 1:
if sys.argv[1].lower() == "lines":
rcmd = rcmd.format("-l")
elif sys.argv[1].lower() == "chars":
rcmd = rcmd.format("-c")
elif sys.argv[1].lower() == "maxlinelength" or sys.argv[1].lower() == "max-line-length" or sys.argv[1].lower() == "mll":
rcmd = rcmd.format("-L")
elif sys.argv[1].lower() == "files":
rcmd = "( find ./ -type d -name .git -prune -o -name '*.%s' -print ) | wc -l"
else:
rcmd = rcmd.format("-l")
else:
rcmd = rcmd.format("-l")
if len(sys.argv) > 2:
if sys.argv[2].lower() == "c":
types = ['c', 'h']
elif sys.argv[2].lower() == "c++" or sys.argv[2].lower() == "cpp":
types = ['cpp', 'h', 'hpp']
elif sys.argv[2].lower() == "allc":
types = ['c', 'cpp', 'h', 'hpp']
elif sys.argv[2].lower() == "python" or sys.argv[2].lower() == "py":
types = ['py']
elif sys.argv[2].lower() == "paracode" or sys.argv[2].lower() == "para":
types = ['para', 'paracode']
elif sys.argv[2].lower() == "main":
types = ['c', 'cpp', 'h', 'hpp', 'py', 'para', 'paracode']
elif sys.argv[2].lower() == "sh":
types = ['sh']
sum = 0
for el in types:
cmd = rcmd % (el)
p = subprocess.Popen([cmd],stdout=subprocess.PIPE,shell=True)
out = int(p.stdout.read().strip())
print("*.%s: %s" % (el, out))
sum += out
print("sum: %d" % (sum))