Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 #!/usr/bin/env python
borlanic 0:380207fcb5c1 2
borlanic 0:380207fcb5c1 3 import os
borlanic 0:380207fcb5c1 4 import re
borlanic 0:380207fcb5c1 5
borlanic 0:380207fcb5c1 6 def main(path='.', pattern=r'#include\s+"([^"]*\.(?:c|cpp))"'):
borlanic 0:380207fcb5c1 7 pattern = re.compile(pattern)
borlanic 0:380207fcb5c1 8
borlanic 0:380207fcb5c1 9 for root, dirs, files in os.walk(path, followlinks=True):
borlanic 0:380207fcb5c1 10 for file in files:
borlanic 0:380207fcb5c1 11 with open(os.path.join(root, file)) as f:
borlanic 0:380207fcb5c1 12 for line in f.read().splitlines():
borlanic 0:380207fcb5c1 13 m = re.search(pattern, line)
borlanic 0:380207fcb5c1 14 if m:
borlanic 0:380207fcb5c1 15 print os.path.relpath(os.path.join(root, m.group(1)))
borlanic 0:380207fcb5c1 16
borlanic 0:380207fcb5c1 17
borlanic 0:380207fcb5c1 18 if __name__ == "__main__":
borlanic 0:380207fcb5c1 19 import sys
borlanic 0:380207fcb5c1 20 main(*sys.argv[1:])
borlanic 0:380207fcb5c1 21