Create the icon cache directory when the extension first runs.
This commit is contained in:
parent
111bb10339
commit
0ad36c00a8
9
main.py
9
main.py
|
@ -46,6 +46,7 @@ class UnicodeChar:
|
||||||
class UnicodeCharExtension(Extension):
|
class UnicodeCharExtension(Extension):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(UnicodeCharExtension, self).__init__()
|
super(UnicodeCharExtension, self).__init__()
|
||||||
|
check_cache_dir()
|
||||||
self._load_character_table()
|
self._load_character_table()
|
||||||
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
|
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
|
||||||
|
|
||||||
|
@ -104,5 +105,13 @@ def create_character_icon(char, font="sans-serif"):
|
||||||
return os.path.join(FILE_PATH, "images/cache/icon_%s.svg" % char.code)
|
return os.path.join(FILE_PATH, "images/cache/icon_%s.svg" % char.code)
|
||||||
|
|
||||||
|
|
||||||
|
def check_cache_dir(path="images/cache"):
|
||||||
|
""" Check if the cache directory exists and if not create it.
|
||||||
|
"""
|
||||||
|
path = os.path.join(FILE_PATH, path)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
UnicodeCharExtension().run()
|
UnicodeCharExtension().run()
|
||||||
|
|
Loading…
Reference in a new issue