Skip to content
Snippets Groups Projects
Commit 1069396e authored by Empiriker's avatar Empiriker
Browse files

Properly initialize Wtp object for non-english editions

parent 0b130bd5
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,7 @@ def load_templates(wiktlang: str): ...@@ -64,7 +64,7 @@ def load_templates(wiktlang: str):
is_done, msg=f"Loading templates for {wiktlang}..." is_done, msg=f"Loading templates for {wiktlang}..."
) )
wxr = get_wiktextract_context(wiktlang) wxr = get_wiktextract_context(wiktlang, mock_get_page=False)
wxr.wtp.db_conn.execute("DELETE FROM pages") wxr.wtp.db_conn.execute("DELETE FROM pages")
wxr.wtp.db_conn.commit() wxr.wtp.db_conn.commit()
...@@ -81,6 +81,7 @@ def load_templates(wiktlang: str): ...@@ -81,6 +81,7 @@ def load_templates(wiktlang: str):
out_f=None, # type: ignore out_f=None, # type: ignore
) )
wxr.wtp.db_conn.commit() wxr.wtp.db_conn.commit()
wxr.wtp.close_db_conn()
stop_progress_indicator(indicator_thread, is_done) stop_progress_indicator(indicator_thread, is_done)
......
...@@ -31,7 +31,7 @@ class CustomWtp(Wtp): ...@@ -31,7 +31,7 @@ class CustomWtp(Wtp):
return original_result return original_result
def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None): def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None, mock_get_page: bool = True):
db_path = f"./sqlite-{wiktlang}.db" db_path = f"./sqlite-{wiktlang}.db"
config = WiktionaryConfig( config = WiktionaryConfig(
dump_file_lang_code=wiktlang, dump_file_lang_code=wiktlang,
...@@ -46,6 +46,8 @@ def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None): ...@@ -46,6 +46,8 @@ def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None):
capture_descendants=True, capture_descendants=True,
capture_inflections=True, capture_inflections=True,
) )
wxr = WiktextractContext(CustomWtp(db_path=db_path), config) config.load_edition_settings()
wtp = CustomWtp(db_path=db_path, lang_code=wiktlang) if mock_get_page else Wtp(db_path=db_path, lang_code=wiktlang)
wxr = WiktextractContext(wtp, config)
return wxr return wxr
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment