anki.foreign_data.mnemosyne
===========================

.. py:module:: anki.foreign_data.mnemosyne

.. autoapi-nested-parse::

   Serializer for Mnemosyne collections.

   Some notes about their structure:
   https://github.com/mnemosyne-proj/mnemosyne/blob/master/mnemosyne/libmnemosyne/docs/source/index.rst

   Anki      | Mnemosyne
   ----------+-----------
   Note      | Fact
   Card Type | Fact View
   Card      | Card
   Notetype  | Card Type



Classes
-------

.. autoapisummary::

   anki.foreign_data.mnemosyne.MnemoFactView
   anki.foreign_data.mnemosyne.FrontOnly
   anki.foreign_data.mnemosyne.FrontBack
   anki.foreign_data.mnemosyne.Vocabulary
   anki.foreign_data.mnemosyne.Cloze
   anki.foreign_data.mnemosyne.MnemoCard
   anki.foreign_data.mnemosyne.MnemoFact


Functions
---------

.. autoapisummary::

   anki.foreign_data.mnemosyne.serialize
   anki.foreign_data.mnemosyne.gather_data
   anki.foreign_data.mnemosyne.open_mnemosyne_db
   anki.foreign_data.mnemosyne.munge_field
   anki.foreign_data.mnemosyne.gather_facts
   anki.foreign_data.mnemosyne.gather_cards_into_facts


Module Contents
---------------

.. py:function:: serialize(db_path: str, deck_id: anki.decks.DeckId) -> str

.. py:function:: gather_data(db: anki.db.DB, deck_id: anki.decks.DeckId) -> anki.foreign_data.ForeignData

.. py:function:: open_mnemosyne_db(db_path: str) -> anki.db.DB

.. py:class:: MnemoFactView

   Bases: :py:obj:`abc.ABC`


   Helper class that provides a standard way to create an ABC using
   inheritance.


   .. py:attribute:: notetype
      :type:  str


   .. py:attribute:: field_keys
      :type:  tuple[str, Ellipsis]


   .. py:method:: foreign_notetype() -> anki.foreign_data.ForeignNotetype
      :classmethod:

      :abstractmethod:



.. py:class:: FrontOnly

   Bases: :py:obj:`MnemoFactView`


   Helper class that provides a standard way to create an ABC using
   inheritance.


   .. py:attribute:: notetype
      :value: 'Mnemosyne-FrontOnly'



   .. py:attribute:: field_keys
      :value: ('f', 'b')



   .. py:method:: foreign_notetype() -> anki.foreign_data.ForeignNotetype
      :classmethod:



.. py:class:: FrontBack

   Bases: :py:obj:`MnemoFactView`


   Helper class that provides a standard way to create an ABC using
   inheritance.


   .. py:attribute:: notetype
      :value: 'Mnemosyne-FrontBack'



   .. py:attribute:: field_keys
      :value: ('f', 'b')



   .. py:method:: foreign_notetype() -> anki.foreign_data.ForeignNotetype
      :classmethod:



.. py:class:: Vocabulary

   Bases: :py:obj:`MnemoFactView`


   Helper class that provides a standard way to create an ABC using
   inheritance.


   .. py:attribute:: notetype
      :value: 'Mnemosyne-Vocabulary'



   .. py:attribute:: field_keys
      :value: ('f', 'p_1', 'm_1', 'n')



   .. py:method:: foreign_notetype() -> anki.foreign_data.ForeignNotetype
      :classmethod:



.. py:class:: Cloze

   Bases: :py:obj:`MnemoFactView`


   Helper class that provides a standard way to create an ABC using
   inheritance.


   .. py:attribute:: notetype
      :value: 'Mnemosyne-Cloze'



   .. py:attribute:: field_keys
      :value: ('text',)



   .. py:method:: foreign_notetype() -> anki.foreign_data.ForeignNotetype
      :classmethod:



.. py:class:: MnemoCard

   .. py:attribute:: fact_view_id
      :type:  str


   .. py:attribute:: tags
      :type:  str


   .. py:attribute:: next_rep
      :type:  int


   .. py:attribute:: last_rep
      :type:  int


   .. py:attribute:: easiness
      :type:  float


   .. py:attribute:: reps
      :type:  int


   .. py:attribute:: lapses
      :type:  int


   .. py:method:: card_ord() -> int


   .. py:method:: is_new() -> bool


   .. py:method:: foreign_card() -> anki.foreign_data.ForeignCard


   .. py:method:: anki_interval() -> int


.. py:class:: MnemoFact

   .. py:attribute:: id
      :type:  int


   .. py:attribute:: fields
      :type:  dict[str, str]


   .. py:attribute:: cards
      :type:  list[MnemoCard]
      :value: []



   .. py:method:: foreign_note(used_fact_views: dict[type[MnemoFactView], bool]) -> anki.foreign_data.ForeignNote


   .. py:method:: fact_view() -> type[MnemoFactView]


   .. py:method:: anki_fields(fact_view: type[MnemoFactView]) -> list[str]


   .. py:method:: anki_tags() -> list[str]


   .. py:method:: foreign_cards() -> list[anki.foreign_data.ForeignCard]


.. py:function:: munge_field(field: str) -> str

.. py:function:: gather_facts(db: anki.db.DB) -> dict[int, MnemoFact]

.. py:function:: gather_cards_into_facts(db: anki.db.DB, facts: dict[int, MnemoFact]) -> None

