From af99d26aa9626dc47b94832662407d18da4dc81e Mon Sep 17 00:00:00 2001 From: 1over137 Date: Tue, 21 May 2024 08:22:41 +0800 Subject: [PATCH] Make book list specific to method --- vocabsieve/importer/GenericImporter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vocabsieve/importer/GenericImporter.py b/vocabsieve/importer/GenericImporter.py index 61bda78..b79a577 100644 --- a/vocabsieve/importer/GenericImporter.py +++ b/vocabsieve/importer/GenericImporter.py @@ -45,7 +45,7 @@ def __init__(self, self.path = path self.setMinimumWidth(500) self.src_name = src_name - self.last_import_books_file = os.path.join(datapath, "last_import_books.json") + self.last_import_books_file = os.path.join(datapath, f"{methodname}_last_import_books.json") self._layout = QFormLayout(self) self._layout.addRow(QLabel( f"

Import {src_name}

" @@ -87,7 +87,7 @@ def __init__(self, self.src_selector._layout = QVBoxLayout(self.src_selector) # type: ignore self._layout.addRow(QLabel("

Select books to extract highlights from

")) try: - with open(self.last_import_books_file, "r") as file: + with open(self.last_import_books_file, "r", encoding='utf-8') as file: book_names = json.load(file) except FileNotFoundError: book_names = [] @@ -243,7 +243,7 @@ def to_anki(self): settings.setValue("last_import_method", self.methodname) settings.setValue("last_import_path", self.path) settings.setValue(f"last_import_date_{self.methodname}", self.lastDate[:10]) - with open(self.last_import_books_file, "w") as file: + with open(self.last_import_books_file, "w", encoding='utf-8') as file: json.dump([cb.text() for cb in self.src_checkboxes if cb.isChecked()], file) self._layout.addRow(QLabel(