From 925781c6a70210bb3c33ffa1af8a0075e6025fa0 Mon Sep 17 00:00:00 2001 From: Mihail Stoyanov Date: Mon, 27 Jun 2016 14:09:43 +0100 Subject: [PATCH] Move non-essential scripts to tools/misc/ --- tools/misc/find_c_includes.py | 21 +++++++++++++++++++++ tools/{ => misc}/remove-device-h.py | 0 2 files changed, 21 insertions(+) create mode 100644 tools/misc/find_c_includes.py rename tools/{ => misc}/remove-device-h.py (100%) diff --git a/tools/misc/find_c_includes.py b/tools/misc/find_c_includes.py new file mode 100644 index 0000000000..e24c6d13c8 --- /dev/null +++ b/tools/misc/find_c_includes.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import os +import re + +def main(path='.', pattern=r'#include\s+"([^"]*\.(?:c|cpp))"'): + pattern = re.compile(pattern) + + for root, dirs, files in os.walk(path, followlinks=True): + for file in files: + with open(os.path.join(root, file)) as f: + for line in f.read().splitlines(): + m = re.search(pattern, line) + if m: + print os.path.relpath(os.path.join(root, m.group(1))) + + +if __name__ == "__main__": + import sys + main(*sys.argv[1:]) + diff --git a/tools/remove-device-h.py b/tools/misc/remove-device-h.py similarity index 100% rename from tools/remove-device-h.py rename to tools/misc/remove-device-h.py