Compare commits
3 Commits
4f4fe2e8d9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 091e7dc6cd | |||
| b99bb3e265 | |||
| e881e5886e |
38
__init__.py
38
__init__.py
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import List
|
||||
from typing import Iterable
|
||||
import albert
|
||||
|
||||
md_iid = '4.0'
|
||||
md_iid = '5.0'
|
||||
md_name = "HTTP Status Codes"
|
||||
md_description = "Show the list of HTTP Status Codes"
|
||||
md_version = "0.0.1"
|
||||
md_version = "1.0.0"
|
||||
md_license = "MIT"
|
||||
md_url = "https://gitea.felix-boers.de/fboers/albert-plugin-python-http-status-codes"
|
||||
md_authors = ["@felixboers"]
|
||||
@@ -84,33 +84,27 @@ codes = [
|
||||
Code(599, "Network Connect Timeout Error", "Network connection timeout error."),
|
||||
]
|
||||
|
||||
def build_query_items(query):
|
||||
results = []
|
||||
def build_query_items(query: str) -> Iterable[albert.StandardItem]:
|
||||
for code in codes:
|
||||
if code.is_match(query.string):
|
||||
results.append(
|
||||
# https://albertlauncher.github.io/reference/classalbert_1_1util_1_1StandardItem.html
|
||||
albert.StandardItem(
|
||||
id=str(code.code),
|
||||
text=f"{code.code} {code.name}",
|
||||
subtext=code.description,
|
||||
actions=[]
|
||||
)
|
||||
if not query or code.is_match(query):
|
||||
# https://albertlauncher.github.io/reference/classalbert_1_1util_1_1StandardItem.html
|
||||
yield albert.StandardItem(
|
||||
id=str(code.code),
|
||||
text=f"{code.code} {code.name}",
|
||||
icon_factory=lambda: albert.Icon.grapheme("‣"),
|
||||
subtext=code.description,
|
||||
actions=[]
|
||||
)
|
||||
return results
|
||||
|
||||
class Plugin(albert.PluginInstance, albert.TriggerQueryHandler):
|
||||
class Plugin(albert.PluginInstance, albert.GeneratorQueryHandler):
|
||||
|
||||
def __init__(self):
|
||||
albert.PluginInstance.__init__(self)
|
||||
albert.TriggerQueryHandler.__init__(self)
|
||||
albert.GeneratorQueryHandler.__init__(self)
|
||||
|
||||
def defaultTrigger(self):
|
||||
return 'http '
|
||||
|
||||
# https://albertlauncher.github.io/reference/classalbert_1_1Query.html
|
||||
def handleTriggerQuery(self, query):
|
||||
if not query.isValid:
|
||||
return
|
||||
|
||||
query.add(build_query_items(query))
|
||||
def items(self, ctx):
|
||||
yield [i for i in build_query_items(ctx.query.strip())]
|
||||
Reference in New Issue
Block a user