コード例 #1
0
ファイル: sched.py プロジェクト: Tiger077/anki
 def _checkLeech(self, card: Card, conf: Dict[str, Any]) -> bool:
     "Leech handler. True if card was a leech."
     lf = conf["leechFails"]
     if not lf:
         return False
     # if over threshold or every half threshold reps after that
     if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0:
         # add a leech tag
         f = card.note()
         f.addTag("leech")
         f.flush()
         # handle
         a = conf["leechAction"]
         if a == LEECH_SUSPEND:
             # if it has an old due, remove it from cram/relearning
             if card.odue:
                 card.due = card.odue
             if card.odid:
                 card.did = card.odid
             card.odue = card.odid = 0
             card.queue = QUEUE_TYPE_SUSPENDED
         # notify UI
         hooks.card_did_leech(card)
         return True
     else:
         return False
コード例 #2
0
ファイル: scheduler.py プロジェクト: ArthurLin821/anki
    def _handle_leech(self, card: Card,
                      new_state: _pb.SchedulingState) -> bool:
        "True if was leech."
        if self.col._backend.state_is_leech(new_state):
            if hooks.card_did_leech.count() > 0:
                hooks.card_did_leech(card)
                # leech hooks assumed that card mutations would be saved for them
                card.mod = intTime()
                card.usn = self.col.usn()
                card.flush()

            return True
        else:
            return False
コード例 #3
0
ファイル: schedv2.py プロジェクト: ArthurLin821/anki
 def _checkLeech(self, card: Card, conf: QueueConfig) -> bool:
     "Leech handler. True if card was a leech."
     lf = conf["leechFails"]
     if not lf:
         return False
     # if over threshold or every half threshold reps after that
     if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0:
         # add a leech tag
         f = card.note()
         f.addTag("leech")
         f.flush()
         # handle
         a = conf["leechAction"]
         if a == LEECH_SUSPEND:
             card.queue = QUEUE_TYPE_SUSPENDED
         # notify UI
         hooks.card_did_leech(card)
         return True
     return False