Move show_invalid_search_error to utils

This commit is contained in:
RumovZ 2021-01-25 23:19:19 +01:00
parent 31a3add848
commit 060fdc824b
2 changed files with 12 additions and 11 deletions

View File

@ -10,8 +10,6 @@ from dataclasses import dataclass
from operator import itemgetter
from typing import List, Sequence, Tuple, cast
from markdown import markdown
import aqt
import aqt.forms
from anki.cards import Card
@ -64,6 +62,7 @@ from aqt.utils import (
saveSplitter,
saveState,
shortcut,
show_invalid_search_error,
showInfo,
showWarning,
tooltip,
@ -91,14 +90,6 @@ class SearchContext:
card_ids: Optional[Sequence[int]] = None
def show_invalid_search_error(err: Exception):
"Render search errors in markdown, then display a warning."
text = str(err)
if isinstance(err, InvalidInput):
text = markdown(text)
showWarning(text)
# Data model
##########################################################################

View File

@ -9,9 +9,11 @@ import subprocess
import sys
from typing import TYPE_CHECKING, Any, List, Optional, Union, cast
from markdown import markdown
import anki
import aqt
from anki.rsbackend import TR # pylint: disable=unused-import
from anki.rsbackend import TR, InvalidInput # pylint: disable=unused-import
from anki.utils import invalidFilename, isMac, isWin, noBundledLibs, versionWithBuild
from aqt.qt import *
from aqt.theme import theme_manager
@ -67,6 +69,14 @@ def showCritical(text, parent=None, help="", title="Anki", textFormat=None):
return showInfo(text, parent, help, "critical", title=title, textFormat=textFormat)
def show_invalid_search_error(err: Exception):
"Render search errors in markdown, then display a warning."
text = str(err)
if isinstance(err, InvalidInput):
text = markdown(text)
showWarning(text)
def showInfo(
text,
parent=False,