tdf#118711 writerfilter: don't hardcode default page description
[LibreOffice.git] / bin / find-headers-to-move-inside-modules.py
blobaf2ca619a4610c1f69c526c8acda3dd3c980a2b4
1 #!/usr/bin/python2
3 # Look for headers inside include/ that can be moved into their respective modules.
4 # Not 100% accurate
6 import subprocess
7 import sys
9 headerSet = set()
10 a = subprocess.Popen("git ls-files include/", stdout=subprocess.PIPE, shell=True)
11 with a.stdout as txt:
12 for line in txt:
13 header = line[8:].strip();
14 if "README" in header: continue
15 if header == "version.hrc": continue
16 # ignore URE headers
17 if header.startswith("IwyuFilter_include.yaml"): continue
18 if header.startswith("cppu/"): continue
19 if header.startswith("cppuhelper/"): continue
20 if header.startswith("osl/"): continue
21 if header.startswith("sal/"): continue
22 if header.startswith("salhelper/"): continue
23 if header.startswith("uno/"): continue
24 # these are direct copies of mozilla code
25 if header.startswith("onlineupdate/mozilla/"): continue
26 headerSet.add(header)
28 headerSetUnused = headerSet.copy()
29 headerSetOnlyInOwnModule = headerSet.copy()
30 a = subprocess.Popen("git grep '^#include <'", stdout=subprocess.PIPE, shell=True)
31 with a.stdout as txt:
32 for line in txt:
33 idx1 = line.find("#include <")
34 idx2 = line.find(">", idx1 + 10)
35 include = line[idx1 + 10 : idx2]
36 headerSetUnused.discard(include)
38 idx1 = line.find("/")
39 includedFromModule = line[0 : idx1]
40 idx1 = include.find("/")
41 module = include[0 : idx1]
42 if module != includedFromModule:
43 headerSetOnlyInOwnModule.discard(include)
45 print "completely unused"
46 print "----------------------------"
47 for x in sorted(headerSetUnused):
48 print x
49 print ""
50 print "only used in own module"
51 print "----------------------------"
52 for x in sorted(headerSetOnlyInOwnModule):
53 print x