o
    ¯b!	  ã                   @   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dee fdd„Zdede	f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„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.
    ÚreturnNc                   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.install©r   N)Ú__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dededefdd„Z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 ©N)r   r   r   )Úselfr   r   r   r   r   r   Ú__init__9   s   
zReactor.__init__r   Nc                 C   s   t | jƒ ¡  d S r   )r
   r   r   )r   r   r   r   r   >   s   zReactor.installr   )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   c                 C   s@   t ƒ D ]}|j| kr| ¡  ddlm} tt|ƒ  S qt| ƒ‚)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   )Úreactor)r   r   r   Útwisted.internetr   r   r   r   )r   Ú	installerr   r   r   r   ÚinstallReactorI   s   

ür"   N)r   Útypingr   r   Úzope.interfacer   r   r   Útwisted.internet.interfacesr   Útwisted.pluginr   r	   Útwisted.python.reflectr
   r   ÚKeyErrorr   r   r   r   r"   r   r   r   r   Ú<module>   s   