mirror of
https://github.com/ankitects/anki.git
synced 2025-12-11 05:46:55 -05:00
move old scheduler files into scheduler/
Includes a hack that should allow existing imports to continue to work; if this breaks things for you, please let me know.
This commit is contained in:
parent
ad973bb701
commit
ec8adf7371
5 changed files with 21 additions and 29 deletions
|
|
@ -30,9 +30,9 @@ from anki.lang import TR, FormatTimeSpan
|
|||
from anki.media import MediaManager, media_paths_from_col_path
|
||||
from anki.models import ModelManager, NoteType
|
||||
from anki.notes import Note
|
||||
from anki.sched import Scheduler as V1Scheduler
|
||||
from anki.scheduler.v1 import Scheduler as V1Scheduler
|
||||
from anki.scheduler.v2 import Scheduler as V2Scheduler
|
||||
from anki.scheduler.v3 import Scheduler as V3TestScheduler
|
||||
from anki.schedv2 import Scheduler as V2Scheduler
|
||||
from anki.sync import SyncAuth, SyncOutput, SyncStatus
|
||||
from anki.tags import TagManager
|
||||
from anki.types import assert_exhaustive
|
||||
|
|
|
|||
|
|
@ -3,8 +3,19 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import anki.scheduler.base as _base
|
||||
|
||||
UnburyCurrentDeck = _base.UnburyCurrentDeck
|
||||
CongratsInfo = _base.CongratsInfo
|
||||
BuryOrSuspend = _base.BuryOrSuspend
|
||||
|
||||
# add aliases to the legacy pathnames
|
||||
import anki.scheduler.v1
|
||||
import anki.scheduler.v2
|
||||
|
||||
sys.modules["anki.sched"] = sys.modules["anki.scheduler.v1"]
|
||||
sys.modules["anki.schedv2"] = sys.modules["anki.scheduler.v2"]
|
||||
anki.sched = sys.modules["anki.scheduler.v1"] # type: ignore
|
||||
anki.schedv2 = sys.modules["anki.scheduler.v2"] # type: ignore
|
||||
|
|
|
|||
|
|
@ -4,12 +4,8 @@
|
|||
from typing import List, Optional, Tuple
|
||||
|
||||
from anki.cards import Card
|
||||
from anki.consts import (
|
||||
CARD_TYPE_RELEARNING,
|
||||
CARD_TYPE_REV,
|
||||
QUEUE_TYPE_DAY_LEARN_RELEARN,
|
||||
)
|
||||
from anki.decks import DeckConfig, QueueConfig
|
||||
from anki.consts import CARD_TYPE_RELEARNING, QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||
from anki.decks import DeckConfig
|
||||
from anki.scheduler.base import SchedulerBase, UnburyCurrentDeck
|
||||
from anki.utils import from_json_bytes, ids2str
|
||||
|
||||
|
|
@ -117,31 +113,15 @@ due = (case when odue>0 then odue else due end), odue = 0, odid = 0, usn = ? whe
|
|||
)
|
||||
return from_json_bytes(self.col._backend.deck_tree_legacy())[5]
|
||||
|
||||
# unit tests
|
||||
def _fuzzIvlRange(self, ivl: int) -> Tuple[int, int]:
|
||||
return (ivl, ivl)
|
||||
# legacy in v3 but used by unit tests; redefined in v2/v1
|
||||
|
||||
def _cardConf(self, card: Card) -> DeckConfig:
|
||||
return self.col.decks.confForDid(card.did)
|
||||
|
||||
def _home_config(self, card: Card) -> DeckConfig:
|
||||
return self.col.decks.confForDid(card.odid or card.did)
|
||||
|
||||
def _newConf(self, card: Card) -> QueueConfig:
|
||||
return self._home_config(card)["new"]
|
||||
|
||||
def _lapseConf(self, card: Card) -> QueueConfig:
|
||||
return self._home_config(card)["lapse"]
|
||||
|
||||
def _revConf(self, card: Card) -> QueueConfig:
|
||||
return self._home_config(card)["rev"]
|
||||
|
||||
def _lrnConf(self, card: Card) -> QueueConfig:
|
||||
if card.type in (CARD_TYPE_REV, CARD_TYPE_RELEARNING):
|
||||
return self._lapseConf(card)
|
||||
else:
|
||||
return self._newConf(card)
|
||||
def _fuzzIvlRange(self, ivl: int) -> Tuple[int, int]:
|
||||
return (ivl, ivl)
|
||||
|
||||
# simple aliases
|
||||
unsuspendCards = SchedulerBase.unsuspend_cards
|
||||
buryCards = SchedulerBase.bury_cards
|
||||
suspendCards = SchedulerBase.suspend_cards
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ from anki import hooks
|
|||
from anki.cards import Card
|
||||
from anki.consts import *
|
||||
from anki.decks import QueueConfig
|
||||
from anki.schedv2 import Scheduler as V2
|
||||
from anki.utils import ids2str, intTime
|
||||
|
||||
from .v2 import Scheduler as V2
|
||||
|
||||
# queue types: 0=new/cram, 1=lrn, 2=rev, 3=day lrn, -1=suspended, -2=buried
|
||||
# revlog types: 0=lrn, 1=rev, 2=relrn, 3=cram
|
||||
# positive revlog intervals are in days (rev), negative in seconds (lrn)
|
||||
Loading…
Reference in a new issue