Skip to content

Commit

Permalink
qmk find: Fix handling of keys with dots in filter functions
Browse files Browse the repository at this point in the history
Filters like `-f "exists(rgb_matrix.split_count")` broke after qmk#22887,
because a plain dict was used instead of the `dotty` wrapper, therefore
only keys with a single component worked.  Fix the implementation of
filtering functions to use the `dotty` wrapper properly, so that keys
with dots could be used in functions again.
  • Loading branch information
sigprof committed Sep 13, 2024
1 parent ae4ab5e commit 2fe7177
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/python/qmk/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,30 @@ class Exists(FilterFunction):
func_name = "exists"

def apply(self, target_info: KeyboardKeymapDesc) -> bool:
return self.key in target_info.data
return self.key in target_info.dotty


class Absent(FilterFunction):
func_name = "absent"

def apply(self, target_info: KeyboardKeymapDesc) -> bool:
return self.key not in target_info.data
return self.key not in target_info.dotty


class Length(FilterFunction):
func_name = "length"

def apply(self, target_info: KeyboardKeymapDesc) -> bool:
return (self.key in target_info.data and len(target_info.data[self.key]) == int(self.value))
info_dotty = target_info.dotty
return (self.key in info_dotty and len(info_dotty[self.key]) == int(self.value))


class Contains(FilterFunction):
func_name = "contains"

def apply(self, target_info: KeyboardKeymapDesc) -> bool:
return (self.key in target_info.data and self.value in target_info.data[self.key])
info_dotty = target_info.dotty
return (self.key in info_dotty and self.value in info_dotty[self.key])


def _get_filter_class(func_name: str, key: str, value: str) -> Optional[FilterFunction]:
Expand Down

0 comments on commit 2fe7177

Please sign in to comment.