anki/pylib
Damien Elmes be994f4102 add support for custom undo steps, and merging multiple actions
Allows add-on authors to define their own label for a group of undoable
operations. For example:

def mark_and_bury(
    *,
    parent: QWidget,
    card_id: CardId,
) -> CollectionOp[OpChanges]:
    def op(col: Collection) -> OpChanges:
        target = col.add_custom_undo_entry("Mark and Bury")
        col.sched.bury_cards([card_id])
        card = col.get_card(card_id)
        col.tags.bulk_add(note_ids=[card.nid], tags="marked")
        return col.merge_undo_entries(target)

    return CollectionOp(parent, op)

The .add_custom_undo_entry() is for adding your own custom actions.
When extending a standard Anki action, instead store `target = 
col.undo_status().last_step` after executing the standard operation.

This started out as a bigger refactor that required a separate
.commit_undoable() call to be run after each operation, instead of
having each operation return changes directly. But that proved to be
somewhat cumbersome in unit tests, and ran the risk of unexpected
behaviour if the caller invoked an operation without remembering to
finalize it.
2021-05-06 16:39:06 +10:00
..
anki add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
rsbridge add missing copyright headers to *.rs 2021-04-13 18:59:16 +10:00
tests support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
tools add missing copyright headers to *.py 2021-04-13 18:45:35 +10:00
.gitignore symlink generated .py/.pyi into tree to fix Python code completion 2020-12-16 11:36:42 +10:00
.isort.cfg start work on more clearly defining backend/protobuf boundaries 2021-01-31 18:55:45 +10:00
.pylintrc support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
BUILD.bazel format_fix -> format; rename svelte-check for consistency 2020-11-12 20:19:32 +10:00
mypy.ini support undo of filtered deck build/empty 2021-03-24 12:56:06 +10:00
orjson.bzl Make orjson optional again 2021-01-07 09:44:40 +10:00
protobuf.bzl update mypy and other Python deps 2021-02-01 15:50:04 +10:00
README.md minor doc updates 2020-12-11 22:37:12 +10:00

Anki's Python library code is in anki/.

The Rust/Python extension module is in rsbridge/; it references the library defined in ../rslib.