55import re
66import threading
77import urllib .request
8- from itertools import product
8+ import builtins
99from locale import getdefaultlocale
1010from pathlib import Path
1111
1212from albert import *
1313
14- md_iid = '2.3'
15- md_version = "2.2 "
14+ md_iid = "3.0"
15+ md_version = "3.0 "
1616md_name = "Emoji"
1717md_description = "Find and copy emojis by name"
1818md_license = "MIT"
@@ -24,7 +24,7 @@ class Plugin(PluginInstance, IndexQueryHandler):
2424
2525 def __init__ (self ):
2626 PluginInstance .__init__ (self )
27- IndexQueryHandler .__init__ (self , self . id , self . name , self . description , defaultTrigger = ':' )
27+ IndexQueryHandler .__init__ (self )
2828 self .thread = None
2929
3030 self ._use_derived = self .readConfig ('use_derived' , bool )
@@ -35,6 +35,9 @@ def __del__(self):
3535 if self .thread and self .thread .is_alive ():
3636 self .thread .join ()
3737
38+ def defaultTrigger (self ):
39+ return ':'
40+
3841 @property
3942 def use_derived (self ):
4043 return self ._use_derived
@@ -69,7 +72,7 @@ def download_file(url: str, path: Path):
6972 with urllib .request .urlopen (request , timeout = 3 ) as response :
7073 if response .getcode () == 200 :
7174 debug (f"Success. Storing to { path } ." )
72- with open (path , 'wb' ) as file :
75+ with builtins . open (path , 'wb' ) as file :
7376 file .write (response .read ())
7477 else :
7578 raise RuntimeError (f"Failed to download { url } . Status code: { response .getcode ()} " )
@@ -157,8 +160,8 @@ def get_annotations(cache_path: Path, use_derived: bool) -> dict:
157160 json_derived = json .load (file_derived )['annotationsDerived' ]['annotations' ]
158161 return json_full | json_derived
159162
160- emojis = get_fully_qualified_emojis (self .cacheLocation )
161- annotations = get_annotations (self .cacheLocation , self .use_derived )
163+ emojis = get_fully_qualified_emojis (self .cacheLocation () )
164+ annotations = get_annotations (self .cacheLocation () , self .use_derived )
162165
163166 def remove_redundancy (sentences ):
164167 sets_of_words = [set (sentence .lower ().split ()) for sentence in sentences ]
@@ -181,7 +184,7 @@ def remove_redundancy(sentences):
181184 non_rgi_emoji = emoji .replace ('\uFE0F ' , '' )
182185 ann = annotations [non_rgi_emoji ]
183186 except KeyError as e :
184- # debug(f"Found no translation for {e}. Emoji will not be available.")
187+ debug (f"Found no translation for { e } . Emoji will not be available." )
185188 continue
186189
187190 title = ann ['tts' ][0 ]
0 commit comments