anki.config#

Config handling

  • To set a config value, use col.set_config(key, val).

  • To get a config value, use col.get_config(key, default=None). In

the case of lists and dictionaries, any changes you make to the returned value will not be saved unless you call set_config(). - To remove a config value, use col.remove_config(key).

For legacy reasons, the config is also exposed as a dict interface as col.conf. To support old code that was mutating inner values, using col.conf[“key”] needs to wrap lists and dicts when returning them. As this is less efficient, please use the col.*_config() API in new code. The legacy set also does not support the new undo handling.

Attributes#

Classes#

ConfigManager

WrappedList

Built-in mutable sequence.

WrappedDict

dict() -> new empty dictionary

Module Contents#

anki.config.Config#
class anki.config.ConfigManager(col: anki.collection.Collection)#
col#
get_immutable(key: str) Any#
set(key: str, val: Any) None#
remove(key: str) anki.collection.OpChanges#
get(key: str, default: Any | None = None) Any#
setdefault(key: str, default: Any) Any#
class anki.config.WrappedList(conf: weakref.ref[ConfigManager], key: str, val: Any)#

Bases: list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

key#
conf#
orig#
class anki.config.WrappedDict(conf: weakref.ref[ConfigManager], key: str, val: Any)#

Bases: dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

key#
conf#
orig#