kerrickstaley / genanki

A Python 3 library for generating Anki decks
MIT License
1.99k stars 150 forks source link

Added simple methods and models #36

Closed benthayer closed 3 years ago

benthayer commented 5 years ago

I was building a project and wrote these methods anyways, so I figured I'd add them to your project. I'm open to changing names or taking suggestions, but this is just something simple that I think would be beneficial.

closes #2

benthayer commented 4 years ago

@kerrickstaley Have you seen this yet?

kerrickstaley commented 4 years ago

Sorry I haven't responded on this PR. One thing that I noticed is that when you generate Anki decks using genanki with these Basic cards, Anki will still create a duplicate card type, even though the card template is exactly the same as the built-in card type. This reduces the benefit of having these built-in card types because you still get extra card types in Anki. I wanted to investigate this before merging this PR but never got around to it.

I still think having this PR is valuable and will work on reviewing/merging it sometime in the next week. Thanks for your contribution to genanki!

benthayer commented 4 years ago

Interesting, I'm not sure why it does that, even with the persistent id. But if you point me into the right direction, I might be able to help! I'm happy to contribute!

kerrickstaley commented 4 years ago

Unfortunately, this PR has a few issues:

kerrickstaley commented 4 years ago

I created a thread on Anki's discussion forum about the duplicate note types: https://forums.ankiweb.net/t/exported-basic-cards-create-duplicate-card-types-when-imported-by-other-users/959

kerrickstaley commented 4 years ago

I think a good way forward is to create a file called stock_models.py that defines BasicModel, BasicAndReversedCardModel, BasicOptionalReversedCardModel, and BasicTypeInTheAnswerModel, and uses the exact same fields and templates as the built-in models (you can create a test deck with one note of each type, export it, then unzip the .apkg file and open the .anki2 file in sqlite3 and do select models from col to see the generated model definitions). For the model names, I would call them Basic (genanki), Basic (and reversed card) (genanki), etc. so that it does not generate the annoying Basic-123ab note type names.

If you have time and want to do the above change, feel free! Otherwise I will do it sometime in the next 2 weeks or so.

kerrickstaley commented 3 years ago

Fixed in ec5847e0faea8de225aa079d101b85f7e08652a6. Turns out 2 weeks ended up being more like 3.5 months :slightly_smiling_face: