2020-01-23 09:19:54 +01:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
|
|
|
"""
|
|
|
|
Legacy support
|
|
|
|
"""
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
from typing import Any, List
|
2020-01-23 09:19:54 +01:00
|
|
|
|
|
|
|
import anki
|
|
|
|
import aqt
|
|
|
|
from aqt.theme import theme_manager
|
|
|
|
|
|
|
|
# Routines removed from pylib/
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
|
2021-02-02 15:00:29 +01:00
|
|
|
def bodyClass(col, card) -> str: # type: ignore
|
2020-01-23 09:19:54 +01:00
|
|
|
print("bodyClass() deprecated")
|
|
|
|
return theme_manager.body_classes_for_card_ord(card.ord)
|
|
|
|
|
|
|
|
|
2021-02-02 15:00:29 +01:00
|
|
|
def allSounds(text) -> List: # type: ignore
|
2020-01-23 09:19:54 +01:00
|
|
|
print("allSounds() deprecated")
|
2021-01-31 09:46:43 +01:00
|
|
|
return aqt.mw.col.media._extract_filenames(text)
|
2020-01-23 09:19:54 +01:00
|
|
|
|
|
|
|
|
2021-02-02 15:00:29 +01:00
|
|
|
def stripSounds(text) -> str: # type: ignore
|
2020-01-23 09:19:54 +01:00
|
|
|
print("stripSounds() deprecated")
|
2021-01-31 09:46:43 +01:00
|
|
|
return aqt.mw.col.media.strip_av_tags(text)
|
2020-01-23 09:19:54 +01:00
|
|
|
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def fmtTimeSpan(
|
|
|
|
time: Any,
|
|
|
|
pad: Any = 0,
|
|
|
|
point: Any = 0,
|
|
|
|
short: Any = False,
|
|
|
|
inTime: Any = False,
|
|
|
|
unit: Any = 99,
|
|
|
|
) -> Any:
|
2021-01-31 09:46:43 +01:00
|
|
|
print("fmtTimeSpan() has become col.format_timespan()")
|
2020-05-24 00:36:50 +02:00
|
|
|
return aqt.mw.col.format_timespan(time)
|
2020-02-23 09:47:16 +01:00
|
|
|
|
|
|
|
|
2020-05-04 05:23:08 +02:00
|
|
|
def install_pylib_legacy() -> None:
|
|
|
|
anki.utils.bodyClass = bodyClass # type: ignore
|
|
|
|
anki.utils.fmtTimeSpan = fmtTimeSpan # type: ignore
|
2020-05-12 17:43:35 +02:00
|
|
|
anki.sound._soundReg = r"\[sound:(.+?)\]" # type: ignore
|
2020-05-04 05:23:08 +02:00
|
|
|
anki.sound.allSounds = allSounds # type: ignore
|
|
|
|
anki.sound.stripSounds = stripSounds # type: ignore
|