anki.decks

Contents

anki.decks#

Attributes#

Classes#

DecksDictProxy

DeckManager

Expose instance methods/vars as camelCase for legacy callers.

Module Contents#

anki.decks.DeckTreeNode#
anki.decks.DeckNameId#
anki.decks.FilteredDeckConfig#
anki.decks.DeckCollapseScope#
anki.decks.DeckConfigsForUpdate#
anki.decks.UpdateDeckConfigs#
anki.decks.Deck#
anki.decks.DeckDict#
anki.decks.DeckConfigDict#
anki.decks.DeckId#
anki.decks.DeckConfigId#
anki.decks.DEFAULT_DECK_ID#
anki.decks.DEFAULT_DECK_CONF_ID#
class anki.decks.DecksDictProxy(col: anki.collection.Collection)#
keys() anki.consts.Any#
values() anki.consts.Any#
items() anki.consts.Any#
class anki.decks.DeckManager(col: anki.collection.Collection)#

Bases: anki._legacy.DeprecatedNamesMixin

Expose instance methods/vars as camelCase for legacy callers.

col#
decks#
save(deck_or_config: DeckDict | DeckConfigDict | None = None) None#

Can be called with either a deck or a deck configuration.

add_normal_deck_with_name(name: str) anki.collection.OpChangesWithId#

If deck exists, return existing id.

add_deck_legacy(deck: DeckDict) anki.collection.OpChangesWithId#

Add a deck created with new_deck_legacy(). Must have id of 0.

id(name: str, create: bool = True, type: DeckConfigId = DeckConfigId(0)) DeckId | None#

Add a deck with NAME. Reuse deck if already exists. Return id as int.

remove(dids: collections.abc.Sequence[DeckId]) anki.collection.OpChangesWithCount#
all_names_and_ids(skip_empty_default: bool = False, include_filtered: bool = True) collections.abc.Sequence[DeckNameId]#

A sorted sequence of deck names and IDs.

id_for_name(name: str) DeckId | None#
get_legacy(did: DeckId) DeckDict | None#
have(id: DeckId) bool#
get_all_legacy() list[DeckDict]#
new_deck() Deck#

Return a new normal deck. It must be added with .add_deck() after a name assigned.

add_deck(deck: Deck) anki.collection.OpChangesWithId#
new_deck_legacy(filtered: bool) DeckDict#
deck_tree() DeckTreeNode#
classmethod find_deck_in_tree(node: DeckTreeNode, deck_id: DeckId) DeckTreeNode | None#
all() list[DeckDict]#

All decks. Expensive; prefer all_names_and_ids()

set_collapsed(deck_id: DeckId, collapsed: bool, scope: DeckCollapseScope) anki.collection.OpChanges#
collapse(did: DeckId) None#
collapse_browser(did: DeckId) None#
count() int#
card_count(dids: DeckId | collections.abc.Iterable[DeckId], include_subdecks: bool) anki.consts.Any#
get(did: DeckId | str, default: bool = True) DeckDict | None#
by_name(name: str) DeckDict | None#

Get deck with NAME, ignoring case.

update(deck: DeckDict, preserve_usn: bool = True) None#

Add or update an existing deck. Used for syncing and merging.

update_dict(deck: DeckDict) anki.collection.OpChanges#
rename(deck: DeckDict | DeckId, new_name: str) anki.collection.OpChanges#

Rename deck prefix to NAME if not exists. Updates children.

reparent(deck_ids: collections.abc.Sequence[DeckId], new_parent: DeckId) anki.collection.OpChangesWithCount#

Rename one or more source decks that were dropped on new_parent. If new_parent is 0, decks will be placed at the top level.

get_deck_configs_for_update(deck_id: DeckId) DeckConfigsForUpdate#
update_deck_configs(input: UpdateDeckConfigs) anki.collection.OpChanges#
all_config() list[DeckConfigDict]#

A list of all deck config.

config_dict_for_deck_id(did: DeckId) DeckConfigDict#
get_config(conf_id: DeckConfigId) DeckConfigDict | None#
update_config(conf: DeckConfigDict, preserve_usn: bool = False) None#

preserve_usn is ignored

add_config(name: str, clone_from: DeckConfigDict | None = None) DeckConfigDict#
add_config_returning_id(name: str, clone_from: DeckConfigDict | None = None) DeckConfigId#
remove_config(id: DeckConfigId) None#

Remove a configuration and update all decks using it.

set_config_id_for_deck_dict(deck: DeckDict, id: DeckConfigId) None#
decks_using_config(conf: DeckConfigDict) list[DeckId]#
restore_to_default(conf: DeckConfigDict) None#
name(did: DeckId, default: bool = False) str#
name_if_exists(did: DeckId) str | None#
cids(did: DeckId, children: bool = False) list[anki.cards.CardId]#
for_card_ids(cids: list[anki.cards.CardId]) list[DeckId]#
set_current(deck: DeckId) anki.collection.OpChanges#
get_current_id() DeckId#

The currently selected deck ID.

current() DeckDict#
active() list[DeckId]#
select(did: DeckId) None#
selected#
static path(name: str) list[str]#
classmethod basename(name: str) str#
classmethod immediate_parent_path(name: str) list[str]#
classmethod immediate_parent(name: str) str | None#
classmethod key(deck: DeckDict) list[str]#
deck_and_child_name_ids(deck_id: DeckId) collections.abc.Iterable[tuple[str, DeckId]]#

The deck of did and all its children, as (name, id).

children(did: DeckId) list[tuple[str, DeckId]]#

All children of did, as (name, id).

child_ids(parent_name: str) collections.abc.Iterable[DeckId]#
deck_and_child_ids(deck_id: DeckId) list[DeckId]#
parents(did: DeckId, name_map: dict[str, DeckDict] | None = None) list[DeckDict]#

All parents of did.

parents_by_name(name: str) list[DeckDict]#

All existing parents of name

new_filtered(name: str) DeckId#

For new code, prefer col.sched.get_or_create_filtered_deck().

is_filtered(did: DeckId | str) bool#
flush() None#
rem(did: DeckId, **legacy_args: bool) None#

Remove the deck. If cardsToo, delete any cards inside.

name_map() dict[str, DeckDict]#
set_deck(cids: list[anki.cards.CardId], did: DeckId) None#
all_ids() list[str]#
all_names(dyn: bool = True, force_default: bool = True) list[str]#