-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update note, deck and model management for Anki 2.1.28+ #100
Conversation
Previously, a new model had an id of None, now it's 0. See: pylib/anki/media.py:171 in f637ac957d206ead619d54d6cf86eb8958ea508c
It's now required.
col.addNote() is legacy. note.flush() is now impossible (and unnecessary) for a new note.
crowd_anki/representation/note.py
Outdated
elif not import_config.ignore_deck_movement: | ||
self.move_cards_to_deck(deck.anki_dict["id"]) | ||
if saner_note_addition: | ||
collection.add_note(self.anki_object, deck.anki_dict["id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean we can directly specify the deck id, and so don't need the did
magic above anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
I had wrapped the did
magic so it only ran for old Anki versions, for compatibility, and now have completely removed it. (Unless I missed part of it.)
Switching to an explicit equality check in note_model.py is not necessary and arguably less "pythonic", but IMO clearer.
Thank you for contributing this! |
Thanks for merging, as well as for having created this incredibly valuable add-on in the first place! |
Uploaded new version to ankiweb |
Fix #92.
Adjust check for "nullness" of model id
Previously, a new model had an id of None, now it's 0.
See:
pylib/anki/media.py:171
in Anki itself (commit f637ac957d206ead619d54d6cf86eb8958ea508c).Pass deck to
collection.decks.save()
It's now required.
Update note addition for Anki 2.1.28 and later
col.addNote()
is legacy.note.flush()
is now impossible (and unnecessary) for a new note.I've written this in a way to preserve compatibility with Anki 2.1.26 (and presumably earlier), since this made it easier to interactively test that behaviour was preserved.
This slightly complicates the code, so might not be desirable.
I think that the fix is correct (it seems to work for me, for both importing a fresh CrowdAnki deck and updating an existing one, for Anki 2.1.28, 2.1.34 and 2.1.35), but I'm not sure, as I'm not too familiar with either CrowdAnki or Anki's Note management (pre- or post- overhaul).
(
pipenv run mamba ./
resulted in no errors.)