U
    P|j!
  ã                   @   s€   d Z ddlmZmZ ddlmZ ddlmZmZ ej	dœdd„Z
deejeej	 ed	œd
d„Zeejejdœdd„ZddgZdS )z°
Construct listening port services from a simple string description.

@see: L{twisted.internet.endpoints.serverFromString}
@see: L{twisted.internet.endpoints.clientFromString}
é    )ÚOptionalÚcast)ÚStreamServerEndpointService)Ú	endpointsÚ
interfaces)Úreturnc                  C   s   ddl m}  ttj| ƒS )Nr   ©Úreactor)Útwisted.internetr	   r   r   ÚIReactorCorer   © r   ú@/tmp/pip-unpacked-wheel-audpp6lv/twisted/application/strports.pyÚ_getReactor   s    r   N)ÚdescriptionÚfactoryr	   r   c                 C   s*   |dkrt ƒ }tt || ¡|ƒ}d|_|S )aj  
    Return the service corresponding to a description.

    @param description: The description of the listening port, in the syntax
        described by L{twisted.internet.endpoints.serverFromString}.
    @type description: C{str}

    @param factory: The protocol factory which will build protocols for
        connections to this service.
    @type factory: L{twisted.internet.interfaces.IProtocolFactory}

    @rtype: C{twisted.application.service.IService}
    @return: the service corresponding to a description of a reliable stream
        server.

    @see: L{twisted.internet.endpoints.serverFromString}
    NT)r   r   r   ZserverFromStringZ_raiseSynchronously)r   r   r	   Zsvcr   r   r   Úservice   s    
 ÿr   )r   r   r   c                 C   s:   ddl m} t | |¡\}}}ttjt|d| ƒ||ŽƒS )ac  
    Listen on a port corresponding to a description.

    @param description: The description of the connecting port, in the syntax
        described by L{twisted.internet.endpoints.serverFromString}.
    @type description: L{str}

    @param factory: The protocol factory which will build protocols on
        connection.
    @type factory: L{twisted.internet.interfaces.IProtocolFactory}

    @rtype: L{twisted.internet.interfaces.IListeningPort}
    @return: the port corresponding to a description of a reliable virtual
        circuit server.

    @see: L{twisted.internet.endpoints.serverFromString}
    r   r   Úlisten)r
   r	   r   Z_parseServerr   r   ÚIListeningPortÚgetattr)r   r   r	   ÚnameÚargsÚkwr   r   r   r   7   s     ÿr   )N)Ú__doc__Útypingr   r   Ztwisted.application.internetr   r
   r   r   r   r   ÚstrZIProtocolFactoryr   r   r   Ú__all__r   r   r   r   Ú<module>   s    	 ýü! þ