Create the icon cache directory when the extension first runs.
This commit is contained in:
		
							parent
							
								
									111bb10339
								
							
						
					
					
						commit
						0ad36c00a8
					
				
					 1 changed files with 9 additions and 0 deletions
				
			
		
							
								
								
									
										9
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								main.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -46,6 +46,7 @@ class UnicodeChar:
 | 
			
		|||
class UnicodeCharExtension(Extension):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        super(UnicodeCharExtension, self).__init__()
 | 
			
		||||
        check_cache_dir()
 | 
			
		||||
        self._load_character_table()
 | 
			
		||||
        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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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__":
 | 
			
		||||
    UnicodeCharExtension().run()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue