U
     T‚g!	  ã                   @   s®   d Z ddlmZmZ ddlmZmZmZ ddl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ƒƒZee dœdd„Zee	dœdd„ZdS )zT
Plugin-based system for enumerating available reactors and installing one of
them.
é    )ÚIterableÚcast)Ú	AttributeÚ	InterfaceÚimplementer)ÚIReactorCore)ÚIPluginÚ
getPlugins)ÚnamedAnyc                   @   s.   e Zd ZdZedƒZedƒZddœ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.
    N©Úreturnc                   C   s   dS )z'
        Install this reactor.
        N© r   r   r   ú@/tmp/pip-unpacked-wheel-1_7di8ic/twisted/application/reactors.pyÚinstall#   s    zIReactorInstaller.install)Ú__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                   @   s0   e Zd ZdZeeedœdd„Zddœdd„ZdS )	ÚReactorz|
    @ivar moduleName: The fully-qualified Python name of the module of which
    the install callable is an attribute.
    ©r   Ú
moduleNamer   c                 C   s   || _ || _|| _d S ©Nr   )Úselfr   r   r   r   r   r   Ú__init__9   s    zReactor.__init__Nr   c                 C   s   t | jƒ ¡  d S r   )r
   r   r   )r   r   r   r   r   >   s    zReactor.install)r   r   r   r   Ústrr   r   r   r   r   r   r   2   s   r   r   c                   C   s   t tƒS )z=
    Return an iterator of L{IReactorInstaller} plugins.
    )r	   r   r   r   r   r   ÚgetReactorTypesB   s    r   )r   r   c                 C   sD   t ƒ D ]0}|j| kr| ¡  ddlm} tt|ƒ  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 Exception: Anything that the specified reactor can raise when installed.
    r   )ÚreactorN)r   r   r   Ztwisted.internetr    r   r   r   )r   Ú	installerr    r   r   r   ÚinstallReactorI   s    

r"   N)r   Útypingr   r   Zzope.interfacer   r   r   Ztwisted.internet.interfacesr   Ztwisted.pluginr   r	   Ztwisted.python.reflectr
   r   ÚKeyErrorr   r   r   r   r"   r   r   r   r   Ú<module>   s   