
Backup 1
mbed-os/tools/git_hooks/find_duplicates.py@0:02dd72d1d465, 2018-04-24 (annotated)
- Committer:
- borlanic
- Date:
- Tue Apr 24 11:45:18 2018 +0000
- Revision:
- 0:02dd72d1d465
BaBoRo_test2 - backup 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:02dd72d1d465 | 1 | from os import walk |
borlanic | 0:02dd72d1d465 | 2 | from os.path import join, abspath, dirname, basename, splitext |
borlanic | 0:02dd72d1d465 | 3 | import sys |
borlanic | 0:02dd72d1d465 | 4 | |
borlanic | 0:02dd72d1d465 | 5 | ROOT = abspath(join(dirname(__file__), "..", "..")) |
borlanic | 0:02dd72d1d465 | 6 | sys.path.insert(0, ROOT) |
borlanic | 0:02dd72d1d465 | 7 | |
borlanic | 0:02dd72d1d465 | 8 | from tools.toolchains.gcc import GCC_ARM |
borlanic | 0:02dd72d1d465 | 9 | from tools.targets import TARGET_MAP |
borlanic | 0:02dd72d1d465 | 10 | from argparse import ArgumentParser |
borlanic | 0:02dd72d1d465 | 11 | |
borlanic | 0:02dd72d1d465 | 12 | if __name__ == "__main__": |
borlanic | 0:02dd72d1d465 | 13 | parser = ArgumentParser("Find duplicate file names within a directory structure") |
borlanic | 0:02dd72d1d465 | 14 | parser.add_argument("dirs", help="Directories to search for duplicate file names" |
borlanic | 0:02dd72d1d465 | 15 | , nargs="*") |
borlanic | 0:02dd72d1d465 | 16 | parser.add_argument("--silent", help="Supress printing of filenames, just return number of duplicates", action="store_true") |
borlanic | 0:02dd72d1d465 | 17 | args = parser.parse_args() |
borlanic | 0:02dd72d1d465 | 18 | |
borlanic | 0:02dd72d1d465 | 19 | toolchain = GCC_ARM(TARGET_MAP["K64F"]) |
borlanic | 0:02dd72d1d465 | 20 | |
borlanic | 0:02dd72d1d465 | 21 | resources = sum([toolchain.scan_resources(d) for d in args.dirs], None) |
borlanic | 0:02dd72d1d465 | 22 | |
borlanic | 0:02dd72d1d465 | 23 | scanned_files = {} |
borlanic | 0:02dd72d1d465 | 24 | |
borlanic | 0:02dd72d1d465 | 25 | exit(resources.detect_duplicates(toolchain)) |
borlanic | 0:02dd72d1d465 | 26 |