mirror of
https://github.com/chenasraf/heb-flip-alfred-workflow.git
synced 2026-05-17 17:48:03 +00:00
Update workflow
This commit is contained in:
17
heb_flip.py
17
heb_flip.py
@@ -6,7 +6,6 @@ import re
|
||||
import sys
|
||||
from maps import *
|
||||
|
||||
# sys.stdout.write("args: " + str(sys.argv) + "\n")
|
||||
|
||||
args = sys.argv[1:]
|
||||
lang = args[0]
|
||||
@@ -14,15 +13,20 @@ query = " ".join(args[1:])
|
||||
|
||||
heb_icon = "85B31B09-7486-435A-A0A7-2A83BEE74B85.png"
|
||||
eng_icon = "5EAA025A-A267-432E-9089-0608B2CBE4D3.png"
|
||||
|
||||
lang_names = {
|
||||
"heb": "Hebrew",
|
||||
"eng": "English",
|
||||
}
|
||||
lang_icons = {
|
||||
"heb": heb_icon,
|
||||
"eng": eng_icon,
|
||||
}
|
||||
|
||||
|
||||
def run(lang, query):
|
||||
res = query.lower()
|
||||
lang_map = to_heb_map if lang == "heb" else to_eng_map
|
||||
lang_map = lang_maps[lang]
|
||||
for k, v in lang_map.items():
|
||||
res = res.replace(k, v)
|
||||
return res
|
||||
@@ -33,10 +37,7 @@ def make_res_item(lang, res):
|
||||
"title": f"Flipped '{res}' to {lang_names[lang]}",
|
||||
"subtitle": f"Copy '{res}' to clipboard",
|
||||
"arg": [res],
|
||||
"icon": {
|
||||
# "type": "filetype",
|
||||
"path": heb_icon if lang == "heb" else eng_icon,
|
||||
},
|
||||
"icon": { "path": lang_icons[lang] },
|
||||
"copy": res,
|
||||
}
|
||||
|
||||
@@ -55,8 +56,4 @@ if re.match(r'[a-z]', query):
|
||||
out['items'] = out['items'][::-1]
|
||||
|
||||
|
||||
# sys.stdout.write("args: " + str(args) + "\n")
|
||||
# sys.stdout.write("lang: " + str(lang) + "\n")
|
||||
# sys.stdout.write("query: " + str(query) + "\n")
|
||||
|
||||
sys.stdout.write(json.dumps(out))
|
||||
|
||||
Reference in New Issue
Block a user