kerrickstaley / genanki

A Python 3 library for generating Anki decks
MIT License
2.06k stars 161 forks source link

Empty list of fields in my note #109

Closed lthiet closed 2 years ago

lthiet commented 2 years ago

Description The list of fields seems to be empty when I am trying to write the created deck as a package. This happens when genanki tries to check for the sort field.

Traceback (most recent call last):
  File "factory.py", line 98, in <module>
    genanki.Package(DECK).write_to_file('output.apkg')
  File "/Users/truvaking/miniconda3/lib/python3.7/site-packages/genanki/package.py", line 40, in write_to_file
    self.write_to_db(cursor, timestamp, id_gen)
  File "/Users/truvaking/miniconda3/lib/python3.7/site-packages/genanki/package.py", line 60, in write_to_db
    deck.write_to_db(cursor, timestamp, id_gen)
  File "/Users/truvaking/miniconda3/lib/python3.7/site-packages/genanki/deck.py", line 67, in write_to_db
    note.write_to_db(cursor, timestamp, self.deck_id, id_gen)
  File "/Users/truvaking/miniconda3/lib/python3.7/site-packages/genanki/note.py", line 163, in write_to_db
    self.sort_field,              # sfld
  File "/Users/truvaking/miniconda3/lib/python3.7/site-packages/genanki/note.py", line 67, in sort_field
    return self._sort_field or self.fields[self.model.sort_field_index]

To reproduce Please run my script to reproduce the error https://github.com/lthiet/anki_region_france

Expected behavior I expect a new file to be written and the fields to be populated

Actual behavior The file is not written and the fields do not seem to be populated

genanki version

Name: genanki
Version: 0.13.0
Summary: Generate Anki decks programmatically
Home-page: http://github.com/kerrickstaley/genanki
Author: Kerrick Staley
Author-email: k@kerrickstaley.com
License: MIT
Location: /Users/truvaking/miniconda3/lib/python3.7/site-packages
Requires: cached-property, chevron, frozendict, pyyaml
Required-by: