diff options
author | Nick Brassel <nick@tzarc.org> | 2023-11-22 12:08:26 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 12:08:26 +1100 |
commit | 0fcd13f55225c4545d828e1898c219ef3cae578f (patch) | |
tree | 81fc9d15c155ee2a50ad27a5eea93d0860ab1ca0 /lib | |
parent | 7ae826476e782ff80ac94d4211bb9f7bb6c42040 (diff) |
[CLI] Remove duplicates from search results (#22528)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/qmk/build_targets.py | 11 | ||||
-rw-r--r-- | lib/python/qmk/search.py | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/python/qmk/build_targets.py b/lib/python/qmk/build_targets.py index fc72022049..16a7ef87a2 100644 --- a/lib/python/qmk/build_targets.py +++ b/lib/python/qmk/build_targets.py @@ -31,6 +31,17 @@ class BuildTarget: def __repr__(self): return f'BuildTarget(keyboard={self.keyboard}, keymap={self.keymap})' + def __eq__(self, __value: object) -> bool: + if not isinstance(__value, BuildTarget): + return False + return self.__repr__() == __value.__repr__() + + def __ne__(self, __value: object) -> bool: + return not self.__eq__(__value) + + def __hash__(self) -> int: + return self.__repr__().__hash__() + def configure(self, parallel: int = None, clean: bool = None, compiledb: bool = None) -> None: if parallel is not None: self._parallel = parallel diff --git a/lib/python/qmk/search.py b/lib/python/qmk/search.py index 9b8bb430b5..84cf6cbe32 100644 --- a/lib/python/qmk/search.py +++ b/lib/python/qmk/search.py @@ -122,7 +122,7 @@ def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str """ if len(filters) == 0: cli.log.info('Preparing target list...') - targets = list(parallel_map(_construct_build_target_kb_km, target_list)) + targets = list(set(parallel_map(_construct_build_target_kb_km, target_list))) else: cli.log.info('Parsing data for all matching keyboard/keymap combinations...') valid_keymaps = [(e[0], e[1], dotty(e[2])) for e in parallel_map(_load_keymap_info, target_list)] @@ -183,7 +183,7 @@ def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str cli.log.info('Preparing target list...') valid_keymaps = [(e[0], e[1], e[2].to_dict() if isinstance(e[2], Dotty) else e[2]) for e in valid_keymaps] # need to convert dotty_dict back to dict because it doesn't survive parallelisation - targets = list(parallel_map(_construct_build_target_kb_km_json, list(valid_keymaps))) + targets = list(set(parallel_map(_construct_build_target_kb_km_json, list(valid_keymaps)))) return targets |