mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Annotate decks.rem as deprecated
This commit is contained in:
parent
c11a394753
commit
dad92e1e22
2 changed files with 26 additions and 2 deletions
|
@ -13,7 +13,7 @@ import anki # pylint: disable=unused-import
|
|||
import anki._backend.backend_pb2 as _pb
|
||||
from anki.consts import *
|
||||
from anki.errors import NotFoundError
|
||||
from anki.utils import from_json_bytes, ids2str, intTime, to_json_bytes
|
||||
from anki.utils import from_json_bytes, ids2str, intTime, legacy_func, to_json_bytes
|
||||
|
||||
# public exports
|
||||
DeckTreeNode = _pb.DeckTreeNode
|
||||
|
@ -130,6 +130,7 @@ class DeckManager:
|
|||
|
||||
return deck["id"]
|
||||
|
||||
@legacy_func(sub="remove")
|
||||
def rem(self, did: int, cardsToo: bool = True, childrenToo: bool = True) -> None:
|
||||
"Remove the deck. If cardsToo, delete any cards inside."
|
||||
if isinstance(did, str):
|
||||
|
|
|
@ -18,7 +18,7 @@ import traceback
|
|||
from contextlib import contextmanager
|
||||
from hashlib import sha1
|
||||
from html.entities import name2codepoint
|
||||
from typing import Any, Iterable, Iterator, List, Match, Optional, Union
|
||||
from typing import Any, Callable, Iterable, Iterator, List, Match, Optional, Union
|
||||
|
||||
from anki.dbproxy import DBProxy
|
||||
|
||||
|
@ -372,3 +372,26 @@ def pointVersion() -> int:
|
|||
from anki.buildinfo import version
|
||||
|
||||
return int(version.split(".")[-1])
|
||||
|
||||
|
||||
# Legacy support
|
||||
##############################################################################
|
||||
|
||||
|
||||
def legacy_func(sub: Optional[str] = None) -> Callable:
|
||||
"""Print a deprecation warning for the decorated callable recommending the use of
|
||||
'sub' instead, if provided.
|
||||
"""
|
||||
if sub:
|
||||
hint = f", use '{sub}' instead"
|
||||
else:
|
||||
hint = ""
|
||||
|
||||
def decorater(func: Callable) -> Callable:
|
||||
def decorated_func(*args: Any, **kwargs: Any) -> Any:
|
||||
print(f"'{func.__name__}' is deprecated{hint}.")
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return decorated_func
|
||||
|
||||
return decorater
|
||||
|
|
Loading…
Reference in a new issue