mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
Fix filter argument order and add example to docstring
This commit is contained in:
parent
4bb9f15bec
commit
ed3e5a405b
2 changed files with 23 additions and 11 deletions
|
@ -220,11 +220,11 @@ class ColpkgExporter(Exporter):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
||||||
gui_hooks.exporter_will_export(ExportFormat.COLPKG, options)
|
options = gui_hooks.exporter_will_export(options, ExportFormat.COLPKG)
|
||||||
|
|
||||||
def on_success(_: None) -> None:
|
def on_success(_: None) -> None:
|
||||||
mw.reopen()
|
mw.reopen()
|
||||||
gui_hooks.exporter_did_export(ExportFormat.COLPKG, options)
|
gui_hooks.exporter_did_export(options, ExportFormat.COLPKG)
|
||||||
tooltip(tr.exporting_collection_exported(), parent=mw)
|
tooltip(tr.exporting_collection_exported(), parent=mw)
|
||||||
|
|
||||||
def on_failure(exception: Exception) -> None:
|
def on_failure(exception: Exception) -> None:
|
||||||
|
@ -258,10 +258,10 @@ class ApkgExporter(Exporter):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
||||||
gui_hooks.exporter_will_export(ExportFormat.APKG, options)
|
options = gui_hooks.exporter_will_export(options, ExportFormat.APKG)
|
||||||
|
|
||||||
def on_success(count: int) -> None:
|
def on_success(count: int) -> None:
|
||||||
gui_hooks.exporter_did_export(ExportFormat.APKG, options)
|
gui_hooks.exporter_did_export(options, ExportFormat.APKG)
|
||||||
tooltip(tr.exporting_note_exported(count=count), parent=mw)
|
tooltip(tr.exporting_note_exported(count=count), parent=mw)
|
||||||
|
|
||||||
QueryOp(
|
QueryOp(
|
||||||
|
@ -292,10 +292,10 @@ class NoteCsvExporter(Exporter):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
||||||
gui_hooks.exporter_will_export(ExportFormat.CSV_NOTES, options)
|
options = gui_hooks.exporter_will_export(options, ExportFormat.CSV_NOTES)
|
||||||
|
|
||||||
def on_success(count: int) -> None:
|
def on_success(count: int) -> None:
|
||||||
gui_hooks.exporter_did_export(ExportFormat.CSV_NOTES, options)
|
gui_hooks.exporter_did_export(options, ExportFormat.CSV_NOTES)
|
||||||
tooltip(tr.exporting_note_exported(count=count), parent=mw)
|
tooltip(tr.exporting_note_exported(count=count), parent=mw)
|
||||||
|
|
||||||
QueryOp(
|
QueryOp(
|
||||||
|
@ -324,10 +324,10 @@ class CardCsvExporter(Exporter):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(mw: aqt.main.AnkiQt, options: Options) -> None:
|
||||||
gui_hooks.exporter_will_export(ExportFormat.CSV_CARDS, options)
|
options = gui_hooks.exporter_will_export(options, ExportFormat.CSV_CARDS)
|
||||||
|
|
||||||
def on_success(count: int) -> None:
|
def on_success(count: int) -> None:
|
||||||
gui_hooks.exporter_did_export(ExportFormat.CSV_CARDS, options)
|
gui_hooks.exporter_did_export(options, ExportFormat.CSV_CARDS)
|
||||||
tooltip(tr.exporting_card_exported(count=count), parent=mw)
|
tooltip(tr.exporting_card_exported(count=count), parent=mw)
|
||||||
|
|
||||||
QueryOp(
|
QueryOp(
|
||||||
|
|
|
@ -819,16 +819,28 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
||||||
Hook(
|
Hook(
|
||||||
name="exporter_will_export",
|
name="exporter_will_export",
|
||||||
args=[
|
args=[
|
||||||
"export_format: aqt.import_export.exporting.ExportFormat",
|
|
||||||
"options: aqt.import_export.exporting.Options",
|
"options: aqt.import_export.exporting.Options",
|
||||||
|
"export_format: aqt.import_export.exporting.ExportFormat",
|
||||||
],
|
],
|
||||||
doc="""Called before collection and deck exports.""",
|
return_type="aqt.import_export.exporting.Options",
|
||||||
|
doc="""Called before collection and deck exports.
|
||||||
|
|
||||||
|
Allows add-ons to be notified of impending deck exports and potentially
|
||||||
|
modify the export options. To perform the export unaltered, please return
|
||||||
|
`options` as is, e.g.:
|
||||||
|
|
||||||
|
def on_exporter_will_export(options: Options, export_format: ExportFormat):
|
||||||
|
if export_format != ExportFormat.APKG:
|
||||||
|
return options
|
||||||
|
options.limit = ...
|
||||||
|
return options
|
||||||
|
""",
|
||||||
),
|
),
|
||||||
Hook(
|
Hook(
|
||||||
name="exporter_did_export",
|
name="exporter_did_export",
|
||||||
args=[
|
args=[
|
||||||
"export_format: aqt.import_export.exporting.ExportFormat",
|
|
||||||
"options: aqt.import_export.exporting.Options",
|
"options: aqt.import_export.exporting.Options",
|
||||||
|
"export_format: aqt.import_export.exporting.ExportFormat",
|
||||||
],
|
],
|
||||||
doc="""Called after collection and deck exports.""",
|
doc="""Called after collection and deck exports.""",
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue