From cd0c38644353d742d291eef63d2ed1b2849a82ec Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Tue, 28 May 2024 16:12:24 -0500 Subject: [PATCH] fix find-filename-conflicts (#1430) * check all trees for conflicts Make sure to merge all specified subtrees when searching for conflicts, instead of separately in each one. Signed-off-by: Taylor Yu * rename existing conflicted filenames Signed-off-by: Taylor Yu --------- Signed-off-by: Taylor Yu --- bin/find-filename-conflicts.py | 20 ++++++++----------- .../device/keyboardio/{twi.c => Imago-twi.c} | 0 ...bsoluteMouse.cpp => TUSBAbsoluteMouse.cpp} | 0 3 files changed, 8 insertions(+), 12 deletions(-) rename plugins/Kaleidoscope-Hardware-Keyboardio-Imago/src/kaleidoscope/device/keyboardio/{twi.c => Imago-twi.c} (100%) rename src/kaleidoscope/driver/hid/tinyusb/{AbsoluteMouse.cpp => TUSBAbsoluteMouse.cpp} (100%) diff --git a/bin/find-filename-conflicts.py b/bin/find-filename-conflicts.py index 558b3d42cd..05e7843883 100755 --- a/bin/find-filename-conflicts.py +++ b/bin/find-filename-conflicts.py @@ -45,26 +45,24 @@ If no conflict is found, the script just prints its status message and exits with zero.""" +from itertools import chain import os import re import sys -cpp_regex = re.compile('.*\.cpp') +suffixes = re.compile(r'\.c(?:pp)?$') -def find_duplicates(root): +def find_duplicates(roots): """Search for files with the same basename, but in different directories in - the tree under . Prints a message for each conflict found, and + the trees under . Prints a message for each conflict found, and returns a count of the number of non-unique basenames.""" # Search the specified tree for matching basenames: basenames = {} - for dir_path, dirs, files in os.walk(root): - for file_name in files: - if cpp_regex.match(file_name): - if file_name not in basenames: - basenames[file_name] = [] - basenames[file_name].append(dir_path) + for dir_path, dirs, files in chain.from_iterable(map(os.walk, roots)): + for file_name in filter(suffixes.search, files): + basenames.setdefault(file_name, []).append(dir_path) conflict_count = 0 for file_name, dirs in basenames.items(): @@ -84,9 +82,7 @@ def find_duplicates(root): def main(args): print('Searching for conflicting filenames...') - exit_code = 0 - for path in args: - exit_code += find_duplicates(path) + exit_code = find_duplicates(args) if exit_code != 0: sys.exit(exit_code) print('No filename conflicts found.') diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Imago/src/kaleidoscope/device/keyboardio/twi.c b/plugins/Kaleidoscope-Hardware-Keyboardio-Imago/src/kaleidoscope/device/keyboardio/Imago-twi.c similarity index 100% rename from plugins/Kaleidoscope-Hardware-Keyboardio-Imago/src/kaleidoscope/device/keyboardio/twi.c rename to plugins/Kaleidoscope-Hardware-Keyboardio-Imago/src/kaleidoscope/device/keyboardio/Imago-twi.c diff --git a/src/kaleidoscope/driver/hid/tinyusb/AbsoluteMouse.cpp b/src/kaleidoscope/driver/hid/tinyusb/TUSBAbsoluteMouse.cpp similarity index 100% rename from src/kaleidoscope/driver/hid/tinyusb/AbsoluteMouse.cpp rename to src/kaleidoscope/driver/hid/tinyusb/TUSBAbsoluteMouse.cpp