Skip to content

Commit

Permalink
feat: use functionalpy
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff committed Oct 27, 2023
1 parent 413edea commit 72d106a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions application/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from collections import defaultdict
from pathlib import Path
from time import sleep
from typing import Annotated, Any, Dict
from typing import Annotated, Any

import sentry_sdk
import typer
from functionalpy import Seq
from personal_mnemonic_medium.card_pipeline import CardPipeline
from personal_mnemonic_medium.exporters.anki.package_generator import (
AnkiPackageGenerator,
Expand Down Expand Up @@ -63,13 +64,11 @@ def main(
input_path=input_dir,
)

decks = defaultdict(list)
grouped_cards = Seq(cards).group_by(lambda card: card.deckname).to_iter()

for card in cards:
decks[card.deckname] += [card]

for deck in decks:
deck_bundle = AnkiPackageGenerator().cards_to_deck_bundle(cards=decks[deck])
for group in grouped_cards:
cards = group.group_contents.to_list()
deck_bundle = AnkiPackageGenerator().cards_to_deck_bundle(cards=cards)
sync_deck(
deck_bundle=deck_bundle,
sync_dir_path=host_output_dir,
Expand Down

0 comments on commit 72d106a

Please sign in to comment.