3
[_ð]1  ã               @   sv   d Z ddlZddlZddlZddlmZ ejZy
ejZW n e	k
rP   dZY nX dd„ Z
dd	„ Zd
d„ Zdd„ ZdS )z*Generic Internet address helper functions.é    Né   )Ú	maybe_ordi'  c             C   s0   | t krtjj|ƒS | tkr(tjj|ƒS t‚dS )a   Convert the textual form of a network address into its binary form.

    *family* is an ``int``, the address family.

    *text* is a ``text``, the textual address.

    Raises ``NotImplementedError`` if the address family specified is not
    implemented.

    Returns a ``binary``.
    N)ÚAF_INETÚdnsÚipv4Ú	inet_atonÚAF_INET6Úipv6ÚNotImplementedError)ÚfamilyÚtext© r   ú-/tmp/pip-build-yz_zf6az/dnspython/dns/inet.pyÚ	inet_pton)   s
    r   c             C   s0   | t krtjj|ƒS | tkr(tjj|ƒS t‚dS )a2  Convert the binary form of a network address into its textual form.

    *family* is an ``int``, the address family.

    *address* is a ``binary``, the network address in binary form.

    Raises ``NotImplementedError`` if the address family specified is not
    implemented.

    Returns a ``text``.
    N)r   r   r   Ú	inet_ntoar   r	   r
   )r   Úaddressr   r   r   Ú	inet_ntop>   s
    r   c             C   sL   yt jj| ƒ tS  tk
rF   yt jj| ƒ tS    t‚Y nX Y nX dS )zåDetermine the address family of a textual-form network address.

    *text*, a ``text``, the textual address.

    Raises ``ValueError`` if the address family cannot be determined
    from the input.

    Returns an ``int``.
    N)r   r   r   r   Ú	Exceptionr	   r   Ú
ValueError)r   r   r   r   Úaf_for_addressS   s    r   c             C   st   y$t tjj| ƒd ƒ}|dko$|dkS  tk
rn   yt tjj| ƒd ƒ}|dkS  tk
rh   t‚Y nX Y nX dS )zÞIs the textual-form network address a multicast address?

    *text*, a ``text``, the textual address.

    Raises ``ValueError`` if the address family cannot be determined
    from the input.

    Returns a ``bool``.
    r   éà   éï   éÿ   N)r   r   r   r   r   r	   r   )r   Úfirstr   r   r   Úis_multicasti   s    r   )Ú__doc__ÚsocketZdns.ipv4r   Zdns.ipv6Ú_compatr   r   r   ÚAttributeErrorr   r   r   r   r   r   r   r   Ú<module>   s   

