From 2fd0e598daec093180ff376da7e8f181e222d8c4 Mon Sep 17 00:00:00 2001 From: Saul Crumpton Date: Mon, 4 May 2020 23:00:28 -0400 Subject: [PATCH] testing fix for the anki 2.1.25 update --- __init__.py | 20 ++++++++++++-------- config.py | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/__init__.py b/__init__.py index 909c559..ce5d72e 100644 --- a/__init__.py +++ b/__init__.py @@ -41,10 +41,11 @@ def new_cards_in_deck(deck_id): # Find settings group ID def find_settings_group_id(name): - dconf = mw.col.decks.dconf + dconf = mw.col.decks.all_config() for k in dconf: - if dconf[k]['name'] == name: - return k + if k['name'] == name: + return k['id'] + # All I want is the group ID return False @@ -128,11 +129,14 @@ def cards_per_day(new_cards, days_left): def update_new_cards_per_day(name, per_day): group_id = find_settings_group_id(name) if group_id: - if group_id in mw.col.decks.dconf: - mw.col.decks.dconf[group_id]["new"]["perDay"] = int(per_day) - # utils.showInfo("updating deadlines disabled") - mw.col.decks.save(mw.col.decks.dconf[group_id]) - #mw.col.decks.flush() + # if we have a group id; check all of thr available confs + for dconf in mw.col.decks.all_config(): + if (group_id==dconf.get('id')): + # if I found the config that I'm trying to update, updat ethe config + dconf["new"]["perDay"] = int(per_day) + # utils.showInfo("updating deadlines disabled") + mw.col.decks.save(dconf) + #mw.col.decks.flush() # Calc new cards per day diff --git a/config.py b/config.py index 4e35166..fe0a5b9 100644 --- a/config.py +++ b/config.py @@ -109,11 +109,11 @@ def readValues(self): self.date="" self.fillFields() mw.addonManager.writeConfig(__name__, self.deadlines) - dconf = mw.col.decks.dconf + dconf = mw.col.decks.all_config() tempID=0 - for confId,conf in dconf.items(): + for conf in dconf: if(conf['name']==deck): - tempID=confId + tempID=conf['id'] if(tempID==0): tempID = mw.col.decks.confId(deck) mw.col.decks.byName(deck)['conf']=tempID