# import the main window object (mw) from aqt
from aqt import mw
# import the "show info" tool from utils.py
from aqt.utils import showInfo, qconnect
# import all of the Qt GUI library
from aqt.qt import *
from bs4 import BeautifulSoup
import requests
def return_search(word):
html = f"https://jisho.org/word/{word}"
webpage = requests.get(html).content
soup = BeautifulSoup(webpage, "html.parser")
meanings_list = []
meanings = soup.find_all(attrs = {"class": "meaning-meaning"})
for count, item in enumerate(meanings):
meanings_list.append(f"{count+1}) {item.get_text()}")
meanings_list = '\n\n'.join(meanings_list)
return meanings_list
def testFunction() -> None:
ids = mw.col.find_cards("tag:jpzr")
for _id in ids:
note = mw.col.getNote(_id)
meaning_list = return_search(note["Focus"])
note["Meaning"] += meaning_list
note.flush()
# create a new menu item, "test"
action = QAction("test", mw)
# set it to call testFunction when it's clicked
qconnect(action.triggered, testFunction)
# and add it to the tools menu
mw.form.menuTools.addAction(action)
I’m getting an error in line 27 of my addon code when trying to find the note - does anyone know how to fix this?