Resolves tdf#142513 - Order of ZoomIn and ZoomOut at Print Preview
[LibreOffice.git] / bin / find-unusedheaders.py
blob7ca9bea4be592b4ff7f869796d6e8e045a2d78fe
1 #!/usr/bin/env python3
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 """
10 Find dirs in:
11 workdir/Dep/CObject
12 workdir/Dep/CxxObject
14 Concat these files and compare them with the output of
15 `git ls-tree HEAD -r --name-only` and report files in the git ls-tree that aren't in the first.
16 """
18 import os
19 import subprocess
22 def get_files_dict_recursively(directory):
23 data = {}
24 for root, _, files in os.walk(directory, topdown=False):
25 for f in files:
26 basename = os.path.splitext(f)[0]
27 data[basename] = os.path.join(root, f)
28 return data
31 def main():
32 data = {}
33 for d in ('workdir/Dep/CObject', 'workdir/Dep/CxxObject'):
34 tmp = get_files_dict_recursively(d)
35 data.update(tmp)
37 gitfiles = subprocess.check_output(['git', 'ls-tree', 'HEAD', '-r', '--name-only']).decode('utf-8').split('\n')
39 for f in gitfiles:
40 ext = os.path.splitext(f)[1]
41 if ext[1:] in ('c', 'cxx', 'h', 'hxx'):
42 tmp = os.path.basename(f)
43 tmp = os.path.splitext(tmp)[0]
44 if tmp not in data:
45 print(f)
47 if __name__ == '__main__':
48 main()