async def register_matrix_action(action_id: str) -> None: """Register a matrix action.""" api = API() loop = api.loop task_registry = api.tasks if task_registry.get(action_id): return Response(content=None, status_code=409) schedule = get_schedule(loop) action = load_db(action_id) matrix_config = load_db(action.config_id) alert = load_db(action.alert_id) update_task, refresh_task = create_register_alert_task( alert, loop, schedule, send_to_matrix_room, matrix_config=matrix_config, ) task_registry[action_id] = True
from util import load_db, find_redirect_and_not_redirect_pages db = load_db() redirect_dict, non_redirect_dict, broken_dict = find_redirect_and_not_redirect_pages(db) for k, v in non_redirect_dict.items(): found = False title = v["title"].lower() #if title[-4:] == ".txt": # не проверяем .txt # continue for k2, v2 in non_redirect_dict.items(): if "категория" in title: for lst in v2["categories"]: if title.replace("категория:", "").replace(" ", "_") == lst["category"].lower(): found = True break for lst in v2["templates"]: if title == lst["title"].lower(): found = True break for lst in v2["links"]: if title == lst["title"].lower(): found = True break if found: break if not found:
def load_matrix_action(action_id: str) -> MatrixAction: """Get Matrix Action by ID.""" return load_db(action_id)
def get_matrix_config(matrix_config_id) -> MatrixConfig: """Get Matrix Config by ID.""" return load_db(matrix_config_id)
def get_alert(alert_id) -> Alert: """Get alert by ID.""" return load_db(alert_id)
import util import sys import logging if __name__ == '__main__': logging.basicConfig(level=logging.INFO) # conn = util.load_db(sys.argv[1], sys.argv[2]) conn = util.load_db(sys.argv[1], ':memory:') (column_names, data) = util.select(conn) print(column_names) print(data[0])