katie/scripts/dblinc.py
Ivailo Monev 39701195bb various cleanups
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
2019-06-07 13:52:57 +00:00

23 lines
655 B
Python
Executable file

#!/usr/bin/python
import os, re
regex = re.compile('(#include [<|"](?:.*)[>|"])')
cppfiles = []
for root, dirs, files in os.walk(os.curdir):
for f in files:
if f.endswith(('.cpp', '.cc', '.hpp', '.h')):
cppfiles.append('%s/%s' % (root, f))
for cpp in cppfiles:
cpp = os.path.realpath(cpp)
cppbase = os.path.basename(cpp)
with open(cpp, 'r') as f:
cppcontent = f.read()
includes = []
for match in regex.findall(cppcontent):
if match in includes:
print('multiple inclusions of: %s, in %s' % (match, cpp))
continue
includes.append(match)