U
    
W[y  ã                   @   s’   d Z ddlmZmZ ddlmZmZmZ ddlm	Z	m
Z
 ddlmZ G dd„ deƒZG dd	„ d	eƒZee	eƒG d
d„ deƒƒZdd„ Zdd„ ZdS )zT
Plugin-based system for enumerating available reactors and installing one of
them.
é    )Úabsolute_importÚdivision)Ú	InterfaceÚ	AttributeÚimplementer)ÚIPluginÚ
getPlugins)ÚnamedAnyc                   @   s(   e Zd ZdZedƒZedƒZdd„ ZdS )ÚIReactorInstallerzB
    Definition of a reactor which can probably be installed.
    zE
    A brief string giving the user-facing name of this reactor.
    zK
    A longer string giving a user-facing description of this reactor.
    c                   C   s   dS )z'
        Install this reactor.
        N© r   r   r   ú>/usr/lib/python3/dist-packages/twisted/application/reactors.pyÚinstall   s    zIReactorInstaller.installN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	shortNameÚdescriptionr   r   r   r   r   r
      s   r
   c                   @   s   e Zd ZdZdS )ÚNoSuchReactorzT
    Raised when an attempt is made to install a reactor which cannot be found.
    N)r   r   r   r   r   r   r   r   r   (   s   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚReactorz|
    @ivar moduleName: The fully-qualified Python name of the module of which
    the install callable is an attribute.
    c                 C   s   || _ || _|| _d S ©N)r   Ú
moduleNamer   )Úselfr   r   r   r   r   r   Ú__init__5   s    zReactor.__init__c                 C   s   t | jƒ ¡  d S r   )r	   r   r   )r   r   r   r   r   ;   s    zReactor.installN)r   r   r   r   r   r   r   r   r   r   r   /   s   r   c                   C   s   t tƒS )z=
    Return an iterator of L{IReactorInstaller} plugins.
    )r   r
   r   r   r   r   ÚgetReactorTypes@   s    r   c                 C   s>   t ƒ D ]*}|j| kr| ¡  ddlm} |  S qt| ƒ‚dS )zß
    Install the reactor with the given C{shortName} attribute.

    @raise NoSuchReactor: If no reactor is found with a matching C{shortName}.

    @raise: anything that the specified reactor can raise when installed.
    r   )ÚreactorN)r   r   r   Ztwisted.internetr   r   )r   Z	installerr   r   r   r   ÚinstallReactorH   s    


r   N)r   Z
__future__r   r   Zzope.interfacer   r   r   Ztwisted.pluginr   r   Ztwisted.python.reflectr	   r
   ÚKeyErrorr   Úobjectr   r   r   r   r   r   r   Ú<module>   s   