2020-01-23 09:19:54 +01:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
|
|
|
"""
|
|
|
|
Legacy support
|
|
|
|
"""
|
|
|
|
|
|
|
|
from typing import List
|
|
|
|
|
|
|
|
import anki
|
|
|
|
import aqt
|
|
|
|
from anki.sound import SoundOrVideoTag
|
|
|
|
from aqt.theme import theme_manager
|
|
|
|
|
|
|
|
# Routines removed from pylib/
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
|
|
|
|
def bodyClass(col, card) -> str:
|
|
|
|
print("bodyClass() deprecated")
|
|
|
|
return theme_manager.body_classes_for_card_ord(card.ord)
|
|
|
|
|
|
|
|
|
|
|
|
def allSounds(text) -> List:
|
|
|
|
print("allSounds() deprecated")
|
2020-01-24 02:06:11 +01:00
|
|
|
text, tags = aqt.mw.col.backend.extract_av_tags(text, True)
|
|
|
|
return [x.filename for x in tags if isinstance(x, SoundOrVideoTag)]
|
2020-01-23 09:19:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
def stripSounds(text) -> str:
|
|
|
|
print("stripSounds() deprecated")
|
|
|
|
return aqt.mw.col.backend.strip_av_tags(text)
|
|
|
|
|
|
|
|
|
2020-02-23 09:47:16 +01:00
|
|
|
def fmtTimeSpan(time, pad=0, point=0, inTime=False, unit=99):
|
|
|
|
print("fmtTimeSpan() has become col.backend.format_time_span()")
|
|
|
|
return aqt.mw.col.backend.format_time_span(time)
|
|
|
|
|
|
|
|
|
2020-01-23 09:19:54 +01:00
|
|
|
def install_pylib_legacy():
|
|
|
|
anki.utils.bodyClass = bodyClass
|
2020-02-23 09:47:16 +01:00
|
|
|
anki.utils.fmtTimeSpan = fmtTimeSpan
|
2020-01-23 09:19:54 +01:00
|
|
|
anki.sound._soundReg = r"\[sound:(.*?)\]"
|
|
|
|
anki.sound.allSounds = allSounds
|
|
|
|
anki.sound.stripSounds = stripSounds
|