__init__.py (2914B)
1 # import the main window object (mw) from aqt 2 from aqt import mw 3 # import the "show info" tool from utils.py 4 from aqt.utils import showInfo 5 # import all of the Qt GUI library 6 from aqt.qt import * 7 8 """MattVsJapan Anki Reset Ease script 9 10 See: https://www.youtube.com/user/MATTvsJapan 11 12 Description: 13 Some people (including me) found the updated red-pill ease values weren't 14 getting pushed from desktop to AnkiWeb without forcing a one-way sync so 15 this version of the script can remove the need to check "Settings > 16 Network > On next sync..." every time. Enable this in the config below. 17 18 Alternatively, just use it to sync automatically before and after ease 19 reset to save a few clicks or keystrokes per day :) 20 21 Usage: 22 1. Sync your other devices with AnkiWeb 23 2. Run this script from Tools -> Reset Ease... 24 3. If the force_after config option is set below, click "Upload to 25 AnkiWeb" on Anki's sync dialog (your other devices can download on 26 next sync) 27 28 Config option combinations (set them below): 29 30 1. Normal sync before and after reset 31 * Set sync_before_reset and sync_after_reset to True 32 33 2. Force sync in one direction after reset 34 * Set sync_after_reset and force_after to True 35 * Might as well set sync_before_reset to True as well 36 37 3. Seen the reset ease dialog enough times? 38 Set skip_reset_notification to True 39 40 4. Same as the original script (no sync) 41 * Set all four options to False 42 """ 43 44 45 ###################################################################### 46 # Configuration 47 ###################################################################### 48 49 sync_before_reset = False 50 sync_after_reset = True 51 force_after = True 52 skip_reset_notification = False 53 54 ###################################################################### 55 # End configuration 56 ###################################################################### 57 58 59 ezFactor = 2500 60 ezFactor2 = ezFactor/10 61 62 def ResetEase(): 63 # sync before resetting ease if enabled 64 if sync_before_reset: 65 mw.onSync() 66 67 # reset ease 68 mw.col.db.execute("update cards set factor = ?", ezFactor) 69 # show a message box 70 if not skip_reset_notification: 71 showInfo("Ease has been reset to " + str(ezFactor2) + "%.") 72 73 # sync after resetting ease if enabled 74 if sync_after_reset: 75 # force a one-way sync if enabled 76 if force_after: 77 mw.col.scm += 1 78 mw.col.setMod() 79 mw.onSync() 80 81 82 # format menu item based on configuration 83 menu_label = 'Reset Ease{}{}'.format( 84 ' + Sync Before' if sync_before_reset else '', 85 (' + {}Sync After' if sync_after_reset else '').format( 86 'Force ' if force_after else '')) 87 88 # create a new menu item 89 action = QAction(menu_label, mw) 90 # set it to call testFunction when it's clicked 91 action.triggered.connect(ResetEase) 92 # and add it to the tools menu 93 mw.form.menuTools.addAction(action) 94