-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid duplicating crowdanki_uuid when cloning deck config
Fix #118. Testing, it seems that I somehow haven't broken the tests despite fiddling with anki/hook_vendor without adding to the overrides. Note that deck_conf_did_add_config is not available as a "legacy" hook, so the new hook mechanism has to be used. It might (or might not) be worth converting the existing hooks to the new mechanism.
- Loading branch information
Showing
2 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .constants import UUID_FIELD_NAME | ||
|
||
def disambiguate_crowdanki_uuid(deck_conf, deck, | ||
config, new_name, | ||
new_conf_id): | ||
new_deck_conf = deck_conf.mw.col.decks.get_config(new_conf_id) | ||
if (new_deck_conf and (UUID_FIELD_NAME in new_deck_conf)): | ||
# Delete rather than generating anew, (with uuid1()) to avoid code duplication. | ||
del new_deck_conf[UUID_FIELD_NAME] | ||
deck_conf.mw.col.decks.update_config(new_deck_conf) |