From 5355c3c25ee8053ca626295086f2b212ce373ab7 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 26 Aug 2020 08:33:35 +1000 Subject: [PATCH] fix description in export screen (thanks to ANH) https://forums.ankiweb.net/t/anki-2-1-31-exporting-display-bug/2669/3 --- pylib/anki/exporting.py | 12 ++++++------ qt/aqt/exporting.py | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pylib/anki/exporting.py b/pylib/anki/exporting.py index 3d72175f9..cc7b6294a 100644 --- a/pylib/anki/exporting.py +++ b/pylib/anki/exporting.py @@ -92,7 +92,7 @@ class Exporter: class TextCardExporter(Exporter): - key = lambda: _("Cards in Plain Text") + key = lambda self: _("Cards in Plain Text") ext = ".txt" includeHTML = True @@ -122,7 +122,7 @@ class TextCardExporter(Exporter): class TextNoteExporter(Exporter): - key = lambda: _("Notes in Plain Text") + key = lambda self: _("Notes in Plain Text") ext = ".txt" includeTags = True includeHTML = True @@ -164,7 +164,7 @@ where cards.id in %s)""" class AnkiExporter(Exporter): - key = lambda: _("Anki 2.0 Deck") + key = lambda self: _("Anki 2.0 Deck") ext = ".anki2" includeSched: Union[bool, None] = False includeMedia = True @@ -313,7 +313,7 @@ class AnkiExporter(Exporter): class AnkiPackageExporter(AnkiExporter): - key = lambda: _("Anki Deck Package") + key = lambda self: _("Anki Deck Package") ext = ".apkg" def __init__(self, col: Collection) -> None: @@ -394,7 +394,7 @@ class AnkiPackageExporter(AnkiExporter): class AnkiCollectionPackageExporter(AnkiPackageExporter): - key = lambda: _("Anki Collection Package") + key = lambda self: _("Anki Collection Package") ext = ".colpkg" verbatim = True includeSched = None @@ -427,7 +427,7 @@ class AnkiCollectionPackageExporter(AnkiPackageExporter): def exporters() -> List[Tuple[str, Any]]: def id(obj): if callable(obj.key): - key_str = obj.key() + key_str = obj.key(obj) else: key_str = obj.key return ("%s (*%s)" % (key_str, obj.ext), obj) diff --git a/qt/aqt/exporting.py b/qt/aqt/exporting.py index 60e965e7d..7df53bcf4 100644 --- a/qt/aqt/exporting.py +++ b/qt/aqt/exporting.py @@ -114,12 +114,16 @@ class ExportDialog(QDialog): deck_name = re.sub('[\\\\/?<>:*|"^]', "_", deck_name) filename = "{0}{1}".format(deck_name, self.exporter.ext) + if callable(self.exporter.key): + key_str = self.exporter.key() + else: + key_str = self.exporter.key while 1: file = getSaveFile( self, _("Export"), "export", - self.exporter.key, + key_str, self.exporter.ext, fname=filename, )