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