refactor: make list of codes static
This commit is contained in:
@@ -18,8 +18,7 @@ class Code:
|
|||||||
self.description = description
|
self.description = description
|
||||||
self.match = f"{code} {name}"
|
self.match = f"{code} {name}"
|
||||||
|
|
||||||
def build_code_list():
|
codes = [
|
||||||
return [
|
|
||||||
Code(100, "Continue", "The client should continue the request."),
|
Code(100, "Continue", "The client should continue the request."),
|
||||||
Code(101, "Switching Protocols", "The transmission protocol is changed according to the client's request."),
|
Code(101, "Switching Protocols", "The transmission protocol is changed according to the client's request."),
|
||||||
Code(102, "Processing", "A time-consuming request is being processed."),
|
Code(102, "Processing", "A time-consuming request is being processed."),
|
||||||
@@ -82,7 +81,7 @@ def build_code_list():
|
|||||||
Code(599, "Network Connect Timeout Error", "Network connection timeout error."),
|
Code(599, "Network Connect Timeout Error", "Network connection timeout error."),
|
||||||
]
|
]
|
||||||
|
|
||||||
def build_query_items(query, codes: List[Code]):
|
def build_query_items(query):
|
||||||
results = []
|
results = []
|
||||||
for code in codes:
|
for code in codes:
|
||||||
if query.string.casefold() in code.match.casefold():
|
if query.string.casefold() in code.match.casefold():
|
||||||
@@ -110,5 +109,4 @@ class Plugin(albert.PluginInstance, albert.TriggerQueryHandler):
|
|||||||
if not query.isValid:
|
if not query.isValid:
|
||||||
return
|
return
|
||||||
|
|
||||||
codes = build_code_list()
|
query.add(build_query_items(query))
|
||||||
query.add(build_query_items(query, codes))
|
|
||||||
Reference in New Issue
Block a user