<commit_before>List Interface
==============

List interface is a unique type of plugin that enables manipulation of its content using flexget normal task operation.
Different phases and interaction with the plugin enable using it as an input, filter or removing entries from it.
It's especially useful for watchlist type list, but not limited to those. Any list that can return entries can be used
as a list interface plugin.

The class of the plugin is based on python's `MutableSet`_ with overrides of its methods where needed.

.. _MutableSet: https://docs.python.org/2/library/collections.html#collections.MutableSet

Usage
-----

As various plugins have different meaning, the specific of the implementation can change. However a few specific override
methods will always be needed, in addition to a few custom ones required by flexget.

Init
~~~~

.. code-block:: python

    class ListInterfaceClass(MutableSet):
        def __init__(self, config):
            self.config.config

The init method should pass the config to a class variable, that will be used by other class methods. Also, any other
global data that is need for the class operation to work should be retrieved. For example, from ``trakt_list``:

.. code-block:: python

    def __init__(self, config):
        self.config = config
        if self.config.get('account') and not self.config.get('username'):
            self.config['username'] = 'me'
        self.session = get_session(self.config.get('account'))
        # Lists may not have modified results if modified then accessed in quick succession.
        self.session.add_domain_limiter(TimedLimiter('trakt.tv', '2 seconds'))
        self._items = None

Note the usage of ``self._items``. In case of an online list, the data should be fetch as little as possible, so a local
cache that can be invalidated should be created. Then a property method that call on that data should be used throughout
the class:

.. code-block:: python
<commit_msg>Fix documentation error (#2246)<commit_after>List Interface
==============

List interface is a unique type of plugin that enables manipulation of its content using flexget normal task operation.
Different phases and interaction with the plugin enable using it as an input, filter or removing entries from it.
It's especially useful for watchlist type list, but not limited to those. Any list that can return entries can be used
as a list interface plugin.

The class of the plugin is based on python's `MutableSet`_ with overrides of its methods where needed.

.. _MutableSet: https://docs.python.org/2/library/collections.html#collections.MutableSet

Usage
-----

As various plugins have different meaning, the specific of the implementation can change. However a few specific override
methods will always be needed, in addition to a few custom ones required by flexget.

Init
~~~~

.. code-block:: python

    class ListInterfaceClass(MutableSet):
        def __init__(self, config):
            self.config = config

The init method should pass the config to a class variable, that will be used by other class methods. Also, any other
global data that is need for the class operation to work should be retrieved. For example, from ``trakt_list``:

.. code-block:: python

    def __init__(self, config):
        self.config = config
        if self.config.get('account') and not self.config.get('username'):
            self.config['username'] = 'me'
        self.session = get_session(self.config.get('account'))
        # Lists may not have modified results if modified then accessed in quick succession.
        self.session.add_domain_limiter(TimedLimiter('trakt.tv', '2 seconds'))
        self._items = None

Note the usage of ``self._items``. In case of an online list, the data should be fetch as little as possible, so a local
cache that can be invalidated should be created. Then a property method that call on that data should be used throughout
the class:

.. code-block:: python

{'fraction_non_alphanumeric': 0.07732997481108313, 'fraction_numerical': 0.0020151133501259445, 'mean_word_length': 3.7443249701314216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5193112', 'n_tokens_mistral': 1002, 'n_tokens_neox': 969, 'n_words': 504}