U
    
W[                     @   sn   d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ dd	 ZeeeG d
d deZdS )z(
Parser for 'haproxy:' string endpoint.
    )implementer)IPlugin)quoteStringArgumentserverFromString!IStreamServerEndpointStringParser)	iteritems   )proxyEndpointc                 C   s.   d dd | D tdd t|D  }|S )a  
    Un-parse the already-parsed args and kwargs back into endpoint syntax.

    @param args: C{:}-separated arguments
    @type args: L{tuple} of native L{str}

    @param kwargs: C{:} and then C{=}-separated keyword arguments

    @type arguments: L{tuple} of native L{str}

    @return: a string equivalent to the original format which this was parsed
        as.
    @rtype: native L{str}
    :c                 S   s   g | ]}t t|qS  r   str).0argr   r   C/usr/lib/python3/dist-packages/twisted/protocols/haproxy/_parser.py
<listcomp>%   s     z#unparseEndpoint.<locals>.<listcomp>c                 S   s,   g | ]$\}}d t t|t t|f qS )z%s=%sr   )r   keyvaluer   r   r   r   &   s   
)joinsortedr   )argskwargsZdescriptionr   r   r   unparseEndpoint   s    r   c                   @   s   e Zd ZdZdZdd ZdS )HAProxyServerParserz
    Stream server endpoint string parser for the HAProxyServerEndpoint type.

    @ivar prefix: See L{IStreamServerEndpointStringParser.prefix}.
    Zhaproxyc                 O   s   t ||}t||}t|S )a[  
        Parse a stream server endpoint from a reactor and string-only arguments
        and keyword arguments.

        @param reactor: The reactor.

        @param args: The parsed string arguments.

        @param kwargs: The parsed keyword arguments.

        @return: a stream server endpoint
        @rtype: L{IStreamServerEndpoint}
        )r   r   r	   )selfZreactorr   r   ZsubdescriptionZwrappedEndpointr   r   r   parseStreamServer7   s    

z%HAProxyServerParser.parseStreamServerN)__name__
__module____qualname____doc__prefixr   r   r   r   r   r   .   s   r   N)r   Zzope.interfacer   Ztwisted.pluginr   Ztwisted.internet.endpointsr   r   r   Ztwisted.python.compatr    r	   r   objectr   r   r   r   r   <module>   s   