ó
ž^Yc           @   s0   d  Z  d d l m Z d e f d     YZ d S(   sB   Implementation of the class that registers and notifies listeners.i˙˙˙˙(   t   _triet   Notifierc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s1   Object that tracks and notifies listener objects.c         C   s   t  j   |  _ d S(   s$   Initialize an empty notifier object.N(   R    t   Triet	   listeners(   t   self(    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/notifier.pyt   __init__   s    c         c   s[   | } xN | rV |  j  j |  } t | d g   } x | D] } | Vq: W| d  } q	 Wd S(   s?  Retrieve listeners for an error_code.

        There may be listeners registered for E1, E100, E101, E110, E112, and
        E126. To get all the listeners for one of E100, E101, E110, E112, or
        E126 you would also need to incorporate the listeners for E1 (since
        they're all in the same class).

        Example usage:

        .. code-block:: python

            from flake8 import notifier

            n = notifier.Notifier()
            # register listeners
            for listener in n.listeners_for('W102'):
                listener.notify(...)
        t   datai˙˙˙˙N(   R   t   findt   getattr(   R   t
   error_codet   patht   nodeR   t   listener(    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/notifier.pyt   listeners_for   s    		c         O   s1   x* |  j  |  D] } | j | | |  q Wd S(   s2   Notify all listeners for the specified error code.N(   R   t   notify(   R   R	   t   argst   kwargsR   (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/notifier.pyR   '   s    c         C   s   |  j  j | |  d S(   s.   Register a listener for a specific error_code.N(   R   t   add(   R   R	   R   (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/notifier.pyt   register_listener,   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/notifier.pyR      s
   			N(   R   t   flake8.pluginsR    t   objectR   (    (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/notifier.pyt   <module>   s   