From 5864b83c25d2c9ada0de13765afdadefd8a60909 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 1 Mar 2026 11:05:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20old=20python=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 69 ----------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index 176772c..0000000 --- a/__init__.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -"""gitmoji Picker for Albert -Usage: g: gitmoji name or description -Examples: - g:bug - g:*""" - -from albertv0 import * - -import os -import json - -__iid__ = "PythonInterface/v0.2" -__prettyname__ = "gitmoji picker" -__version__ = "1.0.0" -__trigger__ = "g:" -__author__ = "Andreas Schneider" -__dependencies__ = [] - -data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "gitmojis.json") - -gitmojis = [] - -def initialize(): - with open(data_path) as f: - data = json.load(f) - - gitmojis.clear() - - for gitmoji in data["gitmojis"]: - gitmoji["tokens"] = [gitmoji["name"].lower()] + gitmoji["description"].lower().split() - gitmojis.append(gitmoji) - -def handleQuery(query): - if not query.isValid or not query.isTriggered: - return [] - - if query.string == "*": - matches = gitmojis - else: - needles = query.string.lower().split() - - matches = [] - for gitmoji in gitmojis: - matchCount = count_matches(gitmoji["tokens"], needles) - if matchCount > 0: - result = dict() - result.update(gitmoji) - result["matchCount"] = matchCount - matches.append(result) - - if not query.isValid: - return [] - - matches = sorted(matches, key=lambda data: data["matchCount"], reverse=True) - - if query.isValid: - return [Item(id=match["name"], completion=match["name"], icon=match["emoji"], text=match["emoji"] + " " + match["code"], subtext=match["description"], actions=[ClipAction("Copy to clipboard", match["emoji"])]) for match in matches] - else: - return [] - -def count_matches(tokens, needles): - count = 0 - for token in tokens: - for needle in needles: - if needle in token: - count += 1 - return count