update importer

This commit is contained in:
Ren Tatsumoto 2023-03-22 04:04:10 +03:00
parent 3fe6baeeba
commit 5b673bdace

View file

@ -3,7 +3,7 @@
# License: GNU GPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import json
from typing import Any
from typing import Any, Collection, Iterable
from .ankiconnect import invoke, request_model_names
from .common import select, get_used_fonts, NoteType, CardTemplate
@ -65,9 +65,15 @@ def send_note_type(model: NoteType):
invoke("createModel", **template_json)
def store_fonts(fonts: list[str]):
def available_fonts(required_fonts: Collection[str]) -> Iterable[str]:
""" Filter required fonts and leave only those available on disk. """
for file in os.listdir(FONTS_DIR):
if file in fonts:
if file in required_fonts:
yield file
def store_fonts(fonts: list[str]):
for file in available_fonts(fonts):
invoke("storeMediaFile", filename=file, path=os.path.join(FONTS_DIR, file))