diff --git a/config.py b/config.py index b377ece..7408baf 100644 --- a/config.py +++ b/config.py @@ -54,8 +54,6 @@ prefs.defaults["preferred_formats"] = ["KFX", "AZW3", "AZW", "MOBI", "EPUB"] prefs.defaults["use_all_formats"] = False prefs.defaults["minimal_x_ray_count"] = 1 -prefs.defaults["en_ipa"] = "ga_ipa" -prefs.defaults["zh_ipa"] = "pinyin" prefs.defaults["choose_format_manually"] = True prefs.defaults["wiktionary_gloss_lang"] = "en" prefs.defaults["kindle_gloss_lang"] = "en" diff --git a/custom_lemmas.py b/custom_lemmas.py index 9c04ed6..e5795b8 100644 --- a/custom_lemmas.py +++ b/custom_lemmas.py @@ -40,7 +40,6 @@ custom_lemmas_folder, get_kindle_klld_path, get_plugin_path, - load_languages_data, ) load_translations() # type: ignore @@ -151,29 +150,6 @@ def init_wiktionary_buttons( ) -> None: from .config import prefs - supported_languages = load_languages_data(get_plugin_path()) - if ( - self.lemma_lang in ["en", "zh"] - and supported_languages[gloss_lang]["gloss_source"] == "kaikki" - ): - self.ipa_button = QComboBox() - if self.lemma_lang == "en": - self.ipa_button.addItem(_("General American"), "ga_ipa") - self.ipa_button.addItem(_("Received Pronunciation"), "rp_ipa") - self.ipa_button.setCurrentText(prefs["en_ipa"]) - elif self.lemma_lang == "zh": - self.ipa_button.addItem(_("Pinyin"), "pinyin") - self.ipa_button.addItem(_("Bopomofo"), "bopomofo") - self.ipa_button.setCurrentText(_(prefs["zh_ipa"])) - - form_layout.addRow( - _("Phonetic transcription system") - if self.lemma_lang == "zh" - else _("International Phonetic Alphabet"), - self.ipa_button, - ) - self.ipa_button.currentIndexChanged.connect(self.change_ipa) - difficulty_label = QLabel(_("Difficulty limit")) difficulty_label.setToolTip( _( @@ -307,11 +283,6 @@ def reset_lemmas(self): self.db_path.unlink() self.reject() - def change_ipa(self): - from .config import prefs - - prefs[f"{self.lemma_lang}_ipa"] = self.ipa_button.currentData() - def set_export_options(self): option_dialog = ExportOptionsDialog(self) if not option_dialog.exec(): diff --git a/import_lemmas.py b/import_lemmas.py index 56b87e1..acc91d6 100644 --- a/import_lemmas.py +++ b/import_lemmas.py @@ -132,51 +132,24 @@ def export_lemmas_job( log: Any = None, notifications: Any = None, ) -> None: - from .config import prefs - from .utils import get_plugin_path, load_languages_data - conn = sqlite3.connect(db_path) with open(export_path, "w", encoding="utf-8") as f: - query_sql = "SELECT lemma, pos, full_def, example" - if not is_kindle: - supported_languages = load_languages_data(get_plugin_path()) - has_multiple_ipas = ( - supported_languages[gloss_lang]["gloss_source"] == "kaikki" - ) - if has_multiple_ipas: - if lemma_lang == "en": - query_sql = f", {prefs['en_ipa']}" - elif lemma_lang == "zh": - query_sql = f", {prefs['zh_ipa']}" - else: - query_sql = ", ipa" - query_sql += ( - " FROM senses JOIN lemmas ON senses.lemma_id = lemmas.id " - "WHERE difficulty <= ?" - ) - + query_sql = """ + SELECT lemma, pos, full_def, example + FROM senses JOIN lemmas ON senses.lemma_id = lemmas.id + WHERE difficulty <= ? + """ if only_enabled: query_sql += " AND enabled = 1" - if is_kindle: - for lemma, pos_type, full_def, example in conn.execute( - query_sql, (difficulty_limit,) - ): - back_text = f"
{pos_type}
{full_def}
" - if example: - back_text += f"{example}" - f.write(f"{lemma}\t{back_text}\n") - else: - for lemma, pos_type, full_def, example, ipa in conn.execute( - query_sql, (difficulty_limit,) - ): - back_text = f"{pos_type}
" - if ipa: - ipa = escape(re.sub(r"\t|\n", " ", ipa)) - back_text += f"{ipa}
" - full_def = escape(re.sub(r"\t|\n", " ", full_def)) - back_text += f"{full_def}
" - if example: - example = escape(re.sub(r"\t|\n", " ", example)) - back_text += f"{example}" - f.write(f"{lemma}\t{back_text}\n") + for lemma, pos_type, full_def, example in conn.execute( + query_sql, (difficulty_limit,) + ): + back_text = f"{pos_type}
" + full_def = escape(re.sub(r"\t|\n", " ", full_def)) + back_text += f"{full_def}
" + if example is not None and len(example) > 0: + example = escape(re.sub(r"\t|\n", " ", example)) + back_text += f"{example}" + f.write(f"{lemma}\t{back_text}\n") + conn.close() diff --git a/utils.py b/utils.py index fb97156..366a17b 100644 --- a/utils.py +++ b/utils.py @@ -26,8 +26,6 @@ class Prefs(TypedDict): preferred_formats: list[str] use_all_formats: bool mal_x_ray_count: int - en_ipa: str - zh_ipa: str choose_format_manually: bool wiktionary_gloss_lang: str kindle_gloss_lang: str