More progress on all entites in MW data load
This commit is contained in:
11
lib/words.py
11
lib/words.py
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user