Includes library modifications to allow access to AIN_4 (AIN_0 / 5)
mbd_os/tools/misc/find_c_includes.py@0:eafc3fd41f75, 2016-09-20 (annotated)
- Committer:
- bryantaylor
- Date:
- Tue Sep 20 21:26:12 2016 +0000
- Revision:
- 0:eafc3fd41f75
hackathon
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bryantaylor | 0:eafc3fd41f75 | 1 | #!/usr/bin/env python |
bryantaylor | 0:eafc3fd41f75 | 2 | |
bryantaylor | 0:eafc3fd41f75 | 3 | import os |
bryantaylor | 0:eafc3fd41f75 | 4 | import re |
bryantaylor | 0:eafc3fd41f75 | 5 | |
bryantaylor | 0:eafc3fd41f75 | 6 | def main(path='.', pattern=r'#include\s+"([^"]*\.(?:c|cpp))"'): |
bryantaylor | 0:eafc3fd41f75 | 7 | pattern = re.compile(pattern) |
bryantaylor | 0:eafc3fd41f75 | 8 | |
bryantaylor | 0:eafc3fd41f75 | 9 | for root, dirs, files in os.walk(path, followlinks=True): |
bryantaylor | 0:eafc3fd41f75 | 10 | for file in files: |
bryantaylor | 0:eafc3fd41f75 | 11 | with open(os.path.join(root, file)) as f: |
bryantaylor | 0:eafc3fd41f75 | 12 | for line in f.read().splitlines(): |
bryantaylor | 0:eafc3fd41f75 | 13 | m = re.search(pattern, line) |
bryantaylor | 0:eafc3fd41f75 | 14 | if m: |
bryantaylor | 0:eafc3fd41f75 | 15 | print os.path.relpath(os.path.join(root, m.group(1))) |
bryantaylor | 0:eafc3fd41f75 | 16 | |
bryantaylor | 0:eafc3fd41f75 | 17 | |
bryantaylor | 0:eafc3fd41f75 | 18 | if __name__ == "__main__": |
bryantaylor | 0:eafc3fd41f75 | 19 | import sys |
bryantaylor | 0:eafc3fd41f75 | 20 | main(*sys.argv[1:]) |
bryantaylor | 0:eafc3fd41f75 | 21 |