aqt.addons

Contents

aqt.addons#

Attributes#

Exceptions#

AbortAddonImport

If raised during add-on import, Anki will silently ignore this exception.

Classes#

Functions#

package_name_valid(→ bool)

download_addon(→ DownloadOk | DownloadError)

Fetch a single add-on from AnkiWeb.

extract_meta_from_download_url(→ ExtractedDownloadMeta)

download_log_to_html(→ str)

describe_log_entry(→ str)

download_encountered_problem(→ bool)

download_and_install_addon(→ DownloadLogEntry)

Download and install a single add-on.

show_log_to_user(→ None)

download_addons(→ None)

fetch_update_info(→ list[anki.collection.AddonInfo])

Fetch update info from AnkiWeb in one or more batches.

check_and_prompt_for_updates(→ None)

check_for_updates(→ None)

handle_update_info(→ None)

prompt_to_update(→ None)

install_or_update_addon(→ None)

installAddonPackages(→ bool)

Module Contents#

exception aqt.addons.AbortAddonImport#

Bases: Exception

If raised during add-on import, Anki will silently ignore this exception. This allows you to terminate loading without an error being shown.

class aqt.addons.InstallOk#
name: str#
conflicts: set[str]#
compatible: bool#
class aqt.addons.InstallError#
errmsg: str#
class aqt.addons.DownloadOk#
data: bytes#
filename: str#
mod_time: int#
min_point_version: int#
max_point_version: int#
branch_index: int#
class aqt.addons.DownloadError#
status_code: int | None = None#
exception: Exception | None = None#
aqt.addons.DownloadLogEntry#
aqt.addons.ANKIWEB_ID_RE#
class aqt.addons.AddonMeta#
dir_name: str#
provided_name: str | None#
enabled: bool#
installed_at: int#
conflicts: list[str]#
min_version: int#
max_version: int#
branch_index: int#
human_version: str | None#
update_enabled: bool#
homepage: str | None#
human_name() → str#
ankiweb_id() → int | None#
compatible() → bool#
is_latest(server_update_time: int) → bool#
page() → str | None#
static from_json_meta(dir_name: str, json_meta: dict[str, Any]) → AddonMeta#
aqt.addons.package_name_valid(name: str) → bool#
class aqt.addons.AddonManager(mw: aqt.main.AnkiQt)#
exts: list[str] = ['.ankiaddon', '.zip']#
mw#
dirty = False#
allAddons() → list[str]#
all_addon_meta() → collections.abc.Iterable[AddonMeta]#
addonsFolder(module: str | None = None) → str#
loadAddons() → None#
onAddonsDialog() → None#
addon_meta(dir_name: str) → AddonMeta#

Get info about an installed add-on.

write_addon_meta(addon: AddonMeta) → None#
addonMeta(module: str) → dict[str, Any]#
writeAddonMeta(module: str, meta: dict[str, Any]) → None#
toggleEnabled(module: str, enable: bool | None = None) → None#
ankiweb_addons() → list[int]#
isEnabled(module: str) → bool#
addonName(module: str) → str#
addonConflicts(module: str) → list[str]#
annotatedName(module: str) → str#
allAddonConflicts() → dict[str, list[str]]#
readManifestFile(zfile: zipfile.ZipFile) → dict[Any, Any]#
install(file: IO | str, manifest: dict[str, Any] | None = None, force_enable: bool = False) → InstallOk | InstallError#

Install add-on from path or file-like object. Metadata is read from the manifest file, with keys overridden by supplying a ‘manifest’ dictionary, except for a non-empty packaged name.

deleteAddon(module: str) → None#
processPackages(paths: list[str], parent: QWidget | None = None, force_enable: bool = False) → tuple[list[str], list[str]]#
update_supported_versions(items: list[anki.collection.AddonInfo]) → None#

Adjust the supported version range after an update check.

AnkiWeb will not have sent us any add-ons that don’t support our version, so this cannot disable add-ons that users are using. It does allow the add-on author to mark an add-on as not supporting a future release, causing the add-on to be disabled when the user upgrades.

get_updated_addons(items: list[anki.collection.AddonInfo]) → list[anki.collection.AddonInfo]#

Return ids of add-ons requiring an update.

addonConfigDefaults(module: str) → dict[str, Any] | None#
set_config_help_action(module: str, action: collections.abc.Callable[[], str]) → None#

Set a callback used to produce config help.

addonConfigHelp(module: str) → str#
addonFromModule(module: str) → str#
static addon_from_module(module: str) → str#
configAction(module: str) → collections.abc.Callable[[], bool | None]#
configUpdatedAction(module: str) → collections.abc.Callable[[Any], None]#
getConfig(module: str) → dict[str, Any] | None#
setConfigAction(module: str, fn: collections.abc.Callable[[], bool | None]) → None#
setConfigUpdatedAction(module: str, fn: collections.abc.Callable[[Any], None]) → None#
writeConfig(module: str, conf: dict) → None#
backupUserFiles(module: str) → None#
restoreUserFiles(sid: str) → None#
setWebExports(module: str, pattern: str) → None#
getWebExports(module: str) → str#
classmethod get_logger(module: str) → logging.Logger#

Return a logger for the given add-on module.

NOTE: This method is static to allow it to be called outside of a running Anki instance, e.g. in add-on unit tests.

has_logger(module: str) → bool#
is_debug_logging_enabled(module: str) → bool#
toggle_debug_logging(module: str, enable: bool) → None#
logs_folder(module: str) → pathlib.Path#
class aqt.addons.AddonsDialog(addonsManager: AddonManager)#

Bases: QDialog

mgr#
mw#
dragEnterEvent(event: QDragEnterEvent) → None#
dropEvent(event: QDropEvent) → None#
reject() → None#
silentlyClose = True#
name_for_addon_list(addon: AddonMeta) → str#
compatible_string(addon: AddonMeta) → str#
should_grey(addon: AddonMeta) → bool#
redrawAddons() → None#
selectedAddons() → list[str]#
onlyOneSelected() → str | None#
selected_addon_meta() → AddonMeta | None#
onToggleEnabled() → None#
onViewPage() → None#
onViewFiles() → None#
onDelete() → None#
onGetAddons() → None#
after_downloading(log: list[DownloadLogEntry]) → None#
onInstallFiles(paths: list[str] | None = None) → bool | None#
check_for_updates() → None#
onConfig() → None#
class aqt.addons.GetAddons(dlg: AddonsDialog)#

Bases: QDialog

addonsDlg#
mgr#
mw#
ids: list[int] = []#
form#
onBrowse() → None#
accept() → None#
aqt.addons.download_addon(client: anki.httpclient.HttpClient, id: int) → DownloadOk | DownloadError#

Fetch a single add-on from AnkiWeb.

class aqt.addons.ExtractedDownloadMeta#
mod_time: int#
min_point_version: int#
max_point_version: int#
branch_index: int#
aqt.addons.extract_meta_from_download_url(url: str) → ExtractedDownloadMeta#
aqt.addons.download_log_to_html(log: list[DownloadLogEntry]) → str#
aqt.addons.describe_log_entry(id_and_entry: DownloadLogEntry) → str#
aqt.addons.download_encountered_problem(log: list[DownloadLogEntry]) → bool#
aqt.addons.download_and_install_addon(mgr: AddonManager, client: anki.httpclient.HttpClient, id: int, force_enable: bool = False) → DownloadLogEntry#

Download and install a single add-on.

class aqt.addons.DownloaderInstaller(parent: QWidget, mgr: AddonManager, client: anki.httpclient.HttpClient)#

Bases: QObject

progressSignal#
mgr#
client#
download(ids: list[int], on_done: collections.abc.Callable[[list[DownloadLogEntry]], None], force_enable: bool = False) → None#
aqt.addons.show_log_to_user(parent: QWidget, log: list[DownloadLogEntry], title: str = 'Anki') → None#
aqt.addons.download_addons(parent: QWidget, mgr: AddonManager, ids: list[int], on_done: collections.abc.Callable[[list[DownloadLogEntry]], None], client: anki.httpclient.HttpClient | None = None, force_enable: bool = False) → None#
class aqt.addons.ChooseAddonsToUpdateList(parent: QWidget, mgr: AddonManager, updated_addons: list[anki.collection.AddonInfo])#

Bases: QListWidget

ADDON_ID_ROLE = 101#
mgr#
updated_addons#
ignore_check_evt = False#
setup() → None#
bool_to_check(check_bool: bool) → Qt.CheckState#
checked(item: QListWidgetItem) → bool#
on_click(item: QListWidgetItem) → None#
on_check(item: QListWidgetItem) → None#
on_double_click(item: QListWidgetItem) → None#
on_context_menu(point: QPoint) → None#
check_item(item: QListWidgetItem, check: Qt.CheckState) → None#

call item.setCheckState without triggering on_check

header_checked(check: Qt.CheckState) → None#
refresh_header_check_state() → None#
get_selected_addon_ids() → list[int]#
save_check_state() → None#
class aqt.addons.ChooseAddonsToUpdateDialog(parent: QWidget, mgr: AddonManager, updated_addons: list[anki.collection.AddonInfo])#

Bases: QDialog

mgr#
updated_addons#
setup() → None#
ask(on_done: collections.abc.Callable[[list[int]], None]) → None#
accept() → None#
aqt.addons.fetch_update_info(ids: list[int]) → list[anki.collection.AddonInfo]#

Fetch update info from AnkiWeb in one or more batches.

aqt.addons.check_and_prompt_for_updates(parent: QWidget, mgr: AddonManager, on_done: collections.abc.Callable[[list[DownloadLogEntry]], None], requested_by_user: bool = True) → None#
aqt.addons.check_for_updates(mgr: AddonManager, on_done: collections.abc.Callable[[list[anki.collection.AddonInfo]], None]) → None#
aqt.addons.handle_update_info(parent: QWidget, mgr: AddonManager, items: list[anki.collection.AddonInfo], on_done: collections.abc.Callable[[list[DownloadLogEntry]], None], requested_by_user: bool = True) → None#
aqt.addons.prompt_to_update(parent: QWidget, mgr: AddonManager, updated_addons: list[anki.collection.AddonInfo], on_done: collections.abc.Callable[[list[DownloadLogEntry]], None], requested_by_user: bool = True) → None#
aqt.addons.install_or_update_addon(parent: QWidget, mgr: AddonManager, addon_id: int, on_done: collections.abc.Callable[[list[DownloadLogEntry]], None]) → None#
class aqt.addons.ConfigEditor(dlg: AddonsDialog, addon: str, conf: dict)#

Bases: QDialog

addon#
conf#
mgr#
form#
onRestoreDefaults() → None#
setupFonts() → None#
updateHelp() → None#
updateText(conf: dict[str, Any]) → None#
onClose() → None#
reject() → None#
accept() → None#
aqt.addons.installAddonPackages(addonsManager: AddonManager, paths: list[str], parent: QWidget | None = None, warn: bool = False, strictly_modal: bool = False, advise_restart: bool = False, force_enable: bool = False) → bool#