Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Remove duplicates from search results #22528

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove duplicates from search results.
  • Loading branch information
tzarc committed Nov 22, 2023
commit 9cc4cc6d6987f0e9ab01574a1a0211f05c5d3272
11 changes: 11 additions & 0 deletions lib/python/qmk/build_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ def __str__(self):
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.keyboard, self.keymap) == (__value.keyboard, __value.keymap)

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
Expand Down
4 changes: 2 additions & 2 deletions lib/python/qmk/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -183,7 +183,7 @@ def f(e):

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

Expand Down