Debian Codegraph @

contrib/header-tools/count-headers

raw
1 #! /usr/bin/python3
2 import os.path
3 import sys
4 import shlex
5 import re
6
7 from headerutils import *
8
9 usage = False
10 src = list ()
11 flist = { }
12 process_h = True
13 process_c = True
14 verbose = False
15 all_inc = True
16 level = 0
17
18 only_use_list = list ()
19
20 for x in sys.argv[1:]:
21 if x[0:2] == "-h":
22 usage = True
23 else:
24 src.append (x)
25
26
27 if not usage and len (src) > 0:
28 incl = { }
29 for fn in src:
30 src = readwholefile (fn)
31 dup = { }
32 for line in src:
33 d = find_pound_include (line, True, True)
34 if d != "" and d[-2:] ==".h":
35 if dup.get (d) == None:
36 if incl.get (d) == None:
37 incl[d] = 1
38 else:
39 incl[d] = incl[d]+ 1
40 dup[d] = 1
41
42 l = list ()
43 for i in incl:
44 l.append ((incl[i], i))
45 l.sort (key=lambda tup:tup[0], reverse=True)
46
47 for f in l:
48 print (str (f[0]) + " : " + f[1])
49
50 else:
51 print ("count-headers file1 [filen]")
52 print ("Count the number of occurrences of all includes across all listed files")
53
54
55
56
57
58