Various playlist editor developments and fixes.
[dcpomatic.git] / hacks / check_includes
1 #!/usr/bin/python
2
3 import sys
4
5 for a in sys.argv[1:]:
6     includes = []
7     for line in open(a, 'r'):
8         if line.startswith('#include'):
9             includes.append(line.strip()[9:])
10
11     std = ['<cstdio>', '<unistd.h>', '<stdexcept>', '<iostream>', '<algorithm>', '<fstream>', '<cstdlib>', '<iomanip>', '<stdint.h>', '<cmath>', '<cassert>', '<cstring>', '<mntent.h>', '<windows.h>', '<shlwapi.h>', '<sys/sysctl.h>', '<mach-o/dyld.h>', '<IOKit/pwr_mgt/IOPMLib.h>', '<sys/types.h>', '<ifaddrs.h>', '<netinet/in.h>', '<arpa/inet.h>', '<cerrno>']
12
13     current_group = 0
14     for i in includes:
15         if i == '"i18n.h"':
16             continue
17
18         if i in std:
19             group = 5
20         elif i.find("<boost/") != -1:
21             group = 4
22         elif i.find("<libxml++/") != -1 or i == '<glib.h>':
23             group = 3
24         elif i.find("<libcxml/") != -1 or i.find("<dcp/") != -1:
25             group = 2
26         elif i.find("\"wx/") != -1:
27             group = 1
28         else:
29             group = 0
30
31         if group < current_group:
32             print '%s: first wrong order is %s' % (a, i)
33             break
34
35         current_group = group
36
37
38