From 4f4fe2e8d931092a0b51ad0554fac69167c56cdb Mon Sep 17 00:00:00 2001 From: Felix Boers Date: Thu, 18 Dec 2025 12:27:27 +0100 Subject: [PATCH] refactor: move matching logic in Code class --- __init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index ea08822..37d7912 100644 --- a/__init__.py +++ b/__init__.py @@ -16,7 +16,10 @@ class Code: self.code = code self.name = name self.description = description - self.match = f"{code} {name}" + self.match = f"{code} {name}".casefold() + + def is_match(self, query: str) -> bool: + return query.casefold() in self.match codes = [ Code(100, "Continue", "The client should continue the request."), @@ -84,10 +87,11 @@ codes = [ def build_query_items(query): results = [] for code in codes: - if query.string.casefold() in code.match.casefold(): + if code.is_match(query.string): results.append( + # https://albertlauncher.github.io/reference/classalbert_1_1util_1_1StandardItem.html albert.StandardItem( - id='uuid', + id=str(code.code), text=f"{code.code} {code.name}", subtext=code.description, actions=[]