mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Rename Options to ExportOptions for better namespacing in add-ons
This commit is contained in:
parent
238e53cd5e
commit
475f9814ca
2 changed files with 16 additions and 16 deletions
|
@ -126,14 +126,14 @@ class ExportDialog(QDialog):
|
||||||
break
|
break
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def options(self, out_path: str) -> Options:
|
def options(self, out_path: str) -> ExportOptions:
|
||||||
limit: ExportLimit = None
|
limit: ExportLimit = None
|
||||||
if self.nids:
|
if self.nids:
|
||||||
limit = NoteIdsLimit(self.nids)
|
limit = NoteIdsLimit(self.nids)
|
||||||
elif current_deck_id := self.current_deck_id():
|
elif current_deck_id := self.current_deck_id():
|
||||||
limit = DeckIdLimit(current_deck_id)
|
limit = DeckIdLimit(current_deck_id)
|
||||||
|
|
||||||
return Options(
|
return ExportOptions(
|
||||||
out_path=out_path,
|
out_path=out_path,
|
||||||
include_scheduling=self.frm.includeSched.isChecked(),
|
include_scheduling=self.frm.includeSched.isChecked(),
|
||||||
include_media=self.frm.includeMedia.isChecked(),
|
include_media=self.frm.includeMedia.isChecked(),
|
||||||
|
@ -166,7 +166,7 @@ class ExportDialog(QDialog):
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Options:
|
class ExportOptions:
|
||||||
out_path: str
|
out_path: str
|
||||||
include_scheduling: bool
|
include_scheduling: bool
|
||||||
include_media: bool
|
include_media: bool
|
||||||
|
@ -200,7 +200,7 @@ class Exporter(ABC):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def export(cls, mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(cls, mw: aqt.main.AnkiQt, options: ExportOptions) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -219,7 +219,7 @@ class ColpkgExporter(Exporter):
|
||||||
return tr.exporting_anki_collection_package()
|
return tr.exporting_anki_collection_package()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export(cls, mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(cls, mw: aqt.main.AnkiQt, options: ExportOptions) -> None:
|
||||||
options = gui_hooks.exporter_will_export(options, cls.format)
|
options = gui_hooks.exporter_will_export(options, cls.format)
|
||||||
|
|
||||||
def on_success(_: None) -> None:
|
def on_success(_: None) -> None:
|
||||||
|
@ -257,7 +257,7 @@ class ApkgExporter(Exporter):
|
||||||
return tr.exporting_anki_deck_package()
|
return tr.exporting_anki_deck_package()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export(cls, mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(cls, mw: aqt.main.AnkiQt, options: ExportOptions) -> None:
|
||||||
options = gui_hooks.exporter_will_export(options, cls.format)
|
options = gui_hooks.exporter_will_export(options, cls.format)
|
||||||
|
|
||||||
def on_success(count: int) -> None:
|
def on_success(count: int) -> None:
|
||||||
|
@ -291,7 +291,7 @@ class NoteCsvExporter(Exporter):
|
||||||
return tr.exporting_notes_in_plain_text()
|
return tr.exporting_notes_in_plain_text()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export(cls, mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(cls, mw: aqt.main.AnkiQt, options: ExportOptions) -> None:
|
||||||
options = gui_hooks.exporter_will_export(options, cls.format)
|
options = gui_hooks.exporter_will_export(options, cls.format)
|
||||||
|
|
||||||
def on_success(count: int) -> None:
|
def on_success(count: int) -> None:
|
||||||
|
@ -323,7 +323,7 @@ class CardCsvExporter(Exporter):
|
||||||
return tr.exporting_cards_in_plain_text()
|
return tr.exporting_cards_in_plain_text()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export(cls, mw: aqt.main.AnkiQt, options: Options) -> None:
|
def export(cls, mw: aqt.main.AnkiQt, options: ExportOptions) -> None:
|
||||||
options = gui_hooks.exporter_will_export(options, cls.format)
|
options = gui_hooks.exporter_will_export(options, cls.format)
|
||||||
|
|
||||||
def on_success(count: int) -> None:
|
def on_success(count: int) -> None:
|
||||||
|
|
|
@ -819,27 +819,27 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
||||||
Hook(
|
Hook(
|
||||||
name="exporter_will_export",
|
name="exporter_will_export",
|
||||||
args=[
|
args=[
|
||||||
"options: aqt.import_export.exporting.Options",
|
"export_options: aqt.import_export.exporting.ExportOptions",
|
||||||
"export_format: aqt.import_export.exporting.ExportFormat",
|
"export_format: aqt.import_export.exporting.ExportFormat",
|
||||||
],
|
],
|
||||||
return_type="aqt.import_export.exporting.Options",
|
return_type="aqt.import_export.exporting.ExportOptions",
|
||||||
doc="""Called before collection and deck exports.
|
doc="""Called before collection and deck exports.
|
||||||
|
|
||||||
Allows add-ons to be notified of impending deck exports and potentially
|
Allows add-ons to be notified of impending deck exports and potentially
|
||||||
modify the export options. To perform the export unaltered, please return
|
modify the export options. To perform the export unaltered, please return
|
||||||
`options` as is, e.g.:
|
`export_options` as is, e.g.:
|
||||||
|
|
||||||
def on_exporter_will_export(options: Options, export_format: ExportFormat):
|
def on_exporter_will_export(export_options: ExportOptions, export_format: ExportFormat):
|
||||||
if export_format != ExportFormat.APKG:
|
if export_format != ExportFormat.APKG:
|
||||||
return options
|
return export_options
|
||||||
options.limit = ...
|
export_options.limit = ...
|
||||||
return options
|
return export_options
|
||||||
""",
|
""",
|
||||||
),
|
),
|
||||||
Hook(
|
Hook(
|
||||||
name="exporter_did_export",
|
name="exporter_did_export",
|
||||||
args=[
|
args=[
|
||||||
"options: aqt.import_export.exporting.Options",
|
"export_options: aqt.import_export.exporting.ExportOptions",
|
||||||
"export_format: aqt.import_export.exporting.ExportFormat",
|
"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