3
[_ð]  ã               @   s‚   d Z ddlZdZdZdZdZdZeeeeedœZdd	„ ej	ƒ D ƒZ
G d
d„ dejjƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )zDNS Opcodes.é    Né   é   é   é   )ÚQUERYÚIQUERYÚSTATUSÚNOTIFYÚUPDATEc             C   s   i | ]\}}||“qS © r   )Ú.0ÚxÚyr   r   ú//tmp/pip-build-yz_zf6az/dnspython/dns/opcode.pyú
<dictcomp>-   s    r   c               @   s   e Zd ZdZdS )ÚUnknownOpcodezAn DNS opcode is unknown.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   0   s   r   c             C   sB   | j ƒ r$t| ƒ}|dkr$|dkr$|S tj| jƒ ƒ}|dkr>t‚|S )z©Convert text into an opcode.

    *text*, a ``text``, the textual opcode

    Raises ``dns.opcode.UnknownOpcode`` if the opcode is unknown.

    Returns an ``int``.
    r   é   N)ÚisdigitÚintÚ_by_textÚgetÚupperr   )ÚtextÚvaluer   r   r   Ú	from_text4   s    
r   c             C   s   | d@ d? S )zpExtract an opcode from DNS message flags.

    *flags*, an ``int``, the DNS flags.

    Returns an ``int``.
    i x  é   r   )Úflagsr   r   r   Ú
from_flagsH   s    r!   c             C   s   | d> d@ S )z™Convert an opcode to a value suitable for ORing into DNS message
    flags.

    *value*, an ``int``, the DNS opcode value.

    Returns an ``int``.
    r   i x  r   )r   r   r   r   Úto_flagsS   s    	r"   c             C   s   t j| ƒ}|dkrt| ƒ}|S )z¦Convert an opcode to text.

    *value*, an ``int`` the opcode value,

    Raises ``dns.opcode.UnknownOpcode`` if the opcode is unknown.

    Returns a ``text``.
    N)Ú	_by_valuer   Ústr)r   r   r   r   r   Úto_text_   s    

r%   c             C   s   t | ƒtkS )zmIs the opcode in flags UPDATE?

    *flags*, an ``int``, the DNS message flags.

    Returns a ``bool``.
    )r!   r
   )r    r   r   r   Ú	is_updateo   s    r&   )r   Zdns.exceptionZdnsr   r   r   r	   r
   r   Úitemsr#   Ú	exceptionZDNSExceptionr   r   r!   r"   r%   r&   r   r   r   r   Ú<module>   s$   