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

.. py:module:: anki.foreign_data

.. autoapi-nested-parse::

   Helpers for serializing third-party collections to a common JSON form.



Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/anki/foreign_data/mnemosyne/index


Classes
-------

.. autoapisummary::

   anki.foreign_data.ForeignCardType
   anki.foreign_data.ForeignNotetype
   anki.foreign_data.ForeignCard
   anki.foreign_data.ForeignNote
   anki.foreign_data.ForeignData
   anki.foreign_data.ForeignDataEncoder


Package Contents
----------------

.. py:class:: ForeignCardType

   .. py:attribute:: name
      :type:  str


   .. py:attribute:: qfmt
      :type:  str


   .. py:attribute:: afmt
      :type:  str


   .. py:method:: front_back() -> ForeignCardType
      :staticmethod:



   .. py:method:: back_front() -> ForeignCardType
      :staticmethod:



   .. py:method:: cloze() -> ForeignCardType
      :staticmethod:



.. py:class:: ForeignNotetype

   .. py:attribute:: name
      :type:  str


   .. py:attribute:: fields
      :type:  list[str]


   .. py:attribute:: templates
      :type:  list[ForeignCardType]


   .. py:attribute:: is_cloze
      :type:  bool
      :value: False



   .. py:method:: basic(name: str) -> ForeignNotetype
      :staticmethod:



   .. py:method:: basic_reverse(name: str) -> ForeignNotetype
      :staticmethod:



   .. py:method:: cloze(name: str) -> ForeignNotetype
      :staticmethod:



.. py:class:: ForeignCard

   Data for creating an Anki card.

   Usually a review card, as the default card generation routine will take care
   of missing new cards.

   due          --  UNIX timestamp
   interval     --  days
   ease_factor  --  decimal fraction (2.5 corresponds to default ease)


   .. py:attribute:: due
      :type:  int
      :value: 0



   .. py:attribute:: interval
      :type:  int
      :value: 1



   .. py:attribute:: ease_factor
      :type:  float
      :value: 2.5



   .. py:attribute:: reps
      :type:  int
      :value: 0



   .. py:attribute:: lapses
      :type:  int
      :value: 0



.. py:class:: ForeignNote

   .. py:attribute:: fields
      :type:  list[str]
      :value: []



   .. py:attribute:: tags
      :type:  list[str]
      :value: []



   .. py:attribute:: notetype
      :type:  str | anki.models.NotetypeId
      :value: ''



   .. py:attribute:: deck
      :type:  str | anki.decks.DeckId
      :value: ''



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



.. py:class:: ForeignData

   .. py:attribute:: notes
      :type:  list[ForeignNote]
      :value: []



   .. py:attribute:: notetypes
      :type:  list[ForeignNotetype]
      :value: []



   .. py:attribute:: default_deck
      :type:  str | anki.decks.DeckId
      :value: ''



   .. py:method:: serialize() -> str


.. py:class:: ForeignDataEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

   Bases: :py:obj:`json.JSONEncoder`


   Extensible JSON <https://json.org> encoder for Python data structures.

   Supports the following objects and types by default:

   +-------------------+---------------+
   | Python            | JSON          |
   +===================+===============+
   | dict              | object        |
   +-------------------+---------------+
   | list, tuple       | array         |
   +-------------------+---------------+
   | str               | string        |
   +-------------------+---------------+
   | int, float        | number        |
   +-------------------+---------------+
   | True              | true          |
   +-------------------+---------------+
   | False             | false         |
   +-------------------+---------------+
   | None              | null          |
   +-------------------+---------------+

   To extend this to recognize other objects, subclass and implement a
   ``.default()`` method with another method that returns a serializable
   object for ``o`` if possible, otherwise it should call the superclass
   implementation (to raise ``TypeError``).



   .. py:method:: default(obj: object) -> dict

      Implement this method in a subclass such that it returns
      a serializable object for ``o``, or calls the base implementation
      (to raise a ``TypeError``).

      For example, to support arbitrary iterators, you could
      implement default like this::

          def default(self, o):
              try:
                  iterable = iter(o)
              except TypeError:
                  pass
              else:
                  return list(iterable)
              # Let the base class default method raise the TypeError
              return super().default(o)




