More progress on all entites in MW data load

This commit is contained in:
Christopher T. Johnson
2024-05-14 11:08:02 -04:00
parent 7c65b466f1
commit 0acba3ed9b
4 changed files with 96 additions and 30 deletions

View File

@@ -40,6 +40,7 @@ class Word:
"""All processing of a dictionary word."""
_words: dict[str, WordType] = {}
_valid = False
def __init__(self, word: str) -> None:
#
@@ -62,14 +63,18 @@ class Word:
"definition": json.loads(query.value("definition")),
}
self.current = Word._words[word]
self._valid = True
return
#
# The code should look at our settings to see if we have an API
# key for MW to decide on the source to use.
#
source = "mw"
self._words[word] = discovered_plugins[source].fetch(word)
if self._words[word] is None:
self._valid = False
return
self.current = Word._words[word]
query.prepare(
"INSERT INTO words "
@@ -81,8 +86,12 @@ class Word:
query.bindValue(":definition", json.dumps(self.current["definition"]))
if not query.exec():
query_error(query)
self._valid = True
return
def isValid(self) -> bool:
return self._valid
@pyqtSlot()
def playSound(self) -> None:
url = discovered_plugins[self.current["source"]].getFirstSound(