From 3ba0c9092fa06a61fbacbb50b7d6fccad438f499 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Fri, 22 Dec 2023 12:30:23 +0100 Subject: [PATCH] feat: support arbitrary subdeck nesting --- .../prompt_converter/prompts/base_anki_prompt.py | 2 +- .../anki_connect/test_ankiconnect_destination.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/personal_mnemonic_medium/domain/prompt_destination/anki_connect/prompt_converter/prompts/base_anki_prompt.py b/personal_mnemonic_medium/domain/prompt_destination/anki_connect/prompt_converter/prompts/base_anki_prompt.py index ebc7d6dd..8dffdb3b 100644 --- a/personal_mnemonic_medium/domain/prompt_destination/anki_connect/prompt_converter/prompts/base_anki_prompt.py +++ b/personal_mnemonic_medium/domain/prompt_destination/anki_connect/prompt_converter/prompts/base_anki_prompt.py @@ -28,7 +28,7 @@ def to_genanki_note(self) -> genanki.Note: def deck(self) -> str: deck_prefix = "anki/deck/" deck_in_tags = ( - tag.replace(deck_prefix, "") + tag.replace(deck_prefix, "").replace("/", "::") for tag in self.tags if tag.startswith(deck_prefix) ) diff --git a/personal_mnemonic_medium/domain/prompt_destination/anki_connect/test_ankiconnect_destination.py b/personal_mnemonic_medium/domain/prompt_destination/anki_connect/test_ankiconnect_destination.py index 02c805c3..46526056 100644 --- a/personal_mnemonic_medium/domain/prompt_destination/anki_connect/test_ankiconnect_destination.py +++ b/personal_mnemonic_medium/domain/prompt_destination/anki_connect/test_ankiconnect_destination.py @@ -63,7 +63,9 @@ def test_ankiconnect_push_prompts(): QAWithoutDoc( question="FakeQuestion", answer="FakeAnswer", - add_tags=["anki/deck/FakeSubdeck"], + add_tags=[ + "anki/deck/FakeSubdeck/FakeSubSubdeck" + ], ), ClozeWithoutDoc( text="FakeText", add_tags=["FakeTag"] @@ -81,7 +83,7 @@ def test_ankiconnect_push_prompts(): ) assert ( import_package_command.package.decks[0].name # type: ignore - == "FakeDeck::FakeSubdeck" + == "FakeDeck::FakeSubdeck::FakeSubSubdeck" ) assert len(import_package_command.package.decks) == 2 # type: ignore