Marco Zecchini
/
Example_RTOS
Rtos API example
mbed-os/tools/misc/find_c_includes.py@0:9fca2b23d0ba, 2019-02-23 (annotated)
- Committer:
- marcozecchini
- Date:
- Sat Feb 23 12:13:36 2019 +0000
- Revision:
- 0:9fca2b23d0ba
final commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcozecchini | 0:9fca2b23d0ba | 1 | #!/usr/bin/env python |
marcozecchini | 0:9fca2b23d0ba | 2 | |
marcozecchini | 0:9fca2b23d0ba | 3 | import os |
marcozecchini | 0:9fca2b23d0ba | 4 | import re |
marcozecchini | 0:9fca2b23d0ba | 5 | |
marcozecchini | 0:9fca2b23d0ba | 6 | def main(path='.', pattern=r'#include\s+"([^"]*\.(?:c|cpp))"'): |
marcozecchini | 0:9fca2b23d0ba | 7 | pattern = re.compile(pattern) |
marcozecchini | 0:9fca2b23d0ba | 8 | |
marcozecchini | 0:9fca2b23d0ba | 9 | for root, dirs, files in os.walk(path, followlinks=True): |
marcozecchini | 0:9fca2b23d0ba | 10 | for file in files: |
marcozecchini | 0:9fca2b23d0ba | 11 | with open(os.path.join(root, file)) as f: |
marcozecchini | 0:9fca2b23d0ba | 12 | for line in f.read().splitlines(): |
marcozecchini | 0:9fca2b23d0ba | 13 | m = re.search(pattern, line) |
marcozecchini | 0:9fca2b23d0ba | 14 | if m: |
marcozecchini | 0:9fca2b23d0ba | 15 | print os.path.relpath(os.path.join(root, m.group(1))) |
marcozecchini | 0:9fca2b23d0ba | 16 | |
marcozecchini | 0:9fca2b23d0ba | 17 | |
marcozecchini | 0:9fca2b23d0ba | 18 | if __name__ == "__main__": |
marcozecchini | 0:9fca2b23d0ba | 19 | import sys |
marcozecchini | 0:9fca2b23d0ba | 20 | main(*sys.argv[1:]) |
marcozecchini | 0:9fca2b23d0ba | 21 |