# `Criterion`

class mnemosyne.libmnemosyne.criterion.Criterion(component_manager, id=None)

  Used to select a subset of cards, e.g. which cards are currently active, i.e. included in the review process.

  The available criteria are stored as classes in the component_manager, the actual instances together with their data are stored in the database.

  active_card_type_added(card_type)
  active_tag_added(tag)
  apply_to_card(card)

    Set the card active or not depending on the criterion. Does not write to the database. Called e.g. after creating, updating or reviewing cards, to see whether these cards should start out their life as active or not.

    The tag and card type creation and deletion functions are callbacks called by the rest of libmnemosyne when these objects get created or destroyed, such that Criteria can update their status if needed.

  card_type_deleted(card_type)
  component_type = 'criterion'
  criterion_type = ''
  data_to_string()

    Convert variables to a string for storage in the database. We don’t use pickle here as that would make it difficult for non-Python programs to read the database.

  data_to_sync_string()

    Convert variables to a string for sending across during syncing. Could be different from ‘data_to_string’, as it should use ids instead of _ids.

  deactivated_card_type_added(card_type)
  deactivated_tag_added(tag)
  instantiate = 1
  is_empty()

    Used to prevent people from creating a criterion which can never contain any cards (e.g. disabling all card types).

  is_tag_active(tag)
  set_data_from_string(data_string)
  set_data_from_sync_string(data_string)
  tag_deleted(tag)

class mnemosyne.libmnemosyne.criterion.CriterionApplier(component_manager, **kwds)

  Can be registered ‘used_for’ a certain Criterion to apply it in bulk to all the cards in the database. Is much faster than fetching each card from the database, calling Criterion.apply_to_card, and storing it back in the database.

  This code is not part of Criterion, because it is dependent on the database backend.

  apply_to_database(criterion)
  component_type = 'criterion_applier'