awesmubarak / koboanki

An anki addon to import saved words from kobo ereaders.
MIT License
9 stars 2 forks source link

KeyError: 'Front' #4

Closed eggwhalefrog closed 3 years ago

eggwhalefrog commented 3 years ago

Crashes and words aren't added after clicking "Import KOBO wordlist"

Debug info:
Anki 2.1.44 (b2b3275f) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-07-24 15:44:57

Caught exception:
Traceback (most recent call last):
  File "anki\notes.py", line 141, in _fieldOrd
KeyError: 'Front'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Roaming\Anki2\addons21\197599239\__init__.py", line 128, in koboanki_menu_action
    add_to_collection(word_defs)
  File "C:\Users\xxx\AppData\Roaming\Anki2\addons21\197599239\__init__.py", line 96, in add_to_collection
    note["Front"] = word
  File "anki\notes.py", line 149, in __setitem__
  File "anki\notes.py", line 143, in _fieldOrd
KeyError: 'Front'
eggwhalefrog commented 3 years ago

Fix is fairly simple, explicitly specify the "Basic" card type in Line 95: note = mw.col.newNote("Basic") instead of note = mw.col.newNote()

awesmubarak commented 3 years ago

Thanks a lot!!!!