3
3kU^…  ã               @   sT   d Z ddlZddddddd	d
ddddddddddddgZdd„ Zdd„ Zdd„ ZdS )z
Utilities
é    NÚPAIRÚPUBÚSUBÚREQÚREPÚDEALERÚROUTERÚPULLÚPUSHÚXPUBÚXSUBÚSTREAMÚSERVERÚCLIENTÚRADIOÚDISHÚGATHERÚSCATTERÚDGRAMc             C   s(   | t jkp&| t jkp&| t jkp&| t jkS )z«Determine if socket needs codec

    :param stype: a ZeroMQ socket type number
    :returns: True if socket type stype requires single-part messages
    :rtype: bool

    )Úzmqr   r   r   r   )Ústype© r   ú%/home/yuhw/zmq/zio/python/zio/util.pyÚneeds_codec    s    	


r   c              C   s   ddl } | jƒ S )zJGuess the local hostname

    :returns: host name
    :rtype: string

    r   N)ÚsocketZgetfqdn)r   r   r   r   Úguess_hostname.   s    r   c             C   s:   t ƒ }x.| D ]&}t|ƒtkr(t|dd�}|j|ƒ qW |S )z”Encode to bytes elements of a list

    :param lst: list of things that can be converted to bytes
    :returns: list of bytes
    :rtype: list

    zutf-8)Úencoding)ÚlistÚtypeÚstrÚbytesÚappend)ÚlstÚretÚelr   r   r   Úbyteify_list8   s    
r%   )Ú__doc__r   Zsocket_namesr   r   r%   r   r   r   r   Ú<module>   s0   
