???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
bWK                 @   s\   d Z ddlZddlZddlZddlmZ ejjdZ	e	fddZ
e	dfd	d
ZdddZdS )zDNS E.164 helpers

@var public_enum_domain: The DNS public ENUM domain, e164.arpa.
@type public_enum_domain: dns.name.Name object
    N   )string_typesz
e164.arpa.c             C   s,   dd | D }|j   tjjdj||dS )au  Convert an E.164 number in textual form into a Name object whose
    value is the ENUM domain name for that number.
    @param text: an E.164 number in textual form.
    @type text: str
    @param origin: The domain in which the number should be constructed.
    The default is e164.arpa.
    @type origin: dns.name.Name object or None
    @rtype: dns.name.Name object
    c             S   s   g | ]}|j  r|qS  )isdigit).0dr   r   /usr/lib/python3.6/e164.py
<listcomp>)   s    zfrom_e164.<locals>.<listcomp>.)origin)reversednsname	from_textjoin)textr   partsr   r   r   	from_e164   s    
r   Tc             C   sb   |dk	r| j |} dd | jD }t|t| jkr@tjjd|j  dj|}|r^d| }|S )a  Convert an ENUM domain name into an E.164 number.
    @param name: the ENUM domain name.
    @type name: dns.name.Name object.
    @param origin: A domain containing the ENUM domain name.  The
    name is relativized to this domain before being converted to text.
    @type origin: dns.name.Name object or None
    @param want_plus_prefix: if True, add a '+' to the beginning of the
    returned number.
    @rtype: str
    Nc             S   s$   g | ]}|j  rt|d kr|qS )r   )r   len)r   r   r   r   r   r	   ;   s    zto_e164.<locals>.<listcomp>z$non-digit labels in ENUM domain name       +)Z
relativizeZlabelsr   r   Z	exceptionSyntaxErrorr   r   )r   r   Zwant_plus_prefixZdlabelsr   r   r   r   to_e164.   s    

r   c             C   s   |dkrt jj }t jj }xl|D ]d}t|tr<t jj|}t jj	| |}y|j
|dS  t jjk
r } z||7 }W Y dd}~X q"X q"W |dS )zLook for NAPTR RRs for the specified number in the specified domains.

    e.g. lookup('16505551212', ['e164.dnspython.org.', 'e164.arpa.'])
    NZNAPTR)r   resolverZget_default_resolverZNXDOMAIN
isinstancer   r   r   Ze164r   query)ZnumberZdomainsr   Ze_nxZdomainZqnameer   r   r   r   E   s    



r   )N)__doc__Zdns.exceptionr   Zdns.nameZdns.resolverZ_compatr   r   r   Zpublic_enum_domainr   r   r   r   r   r   r   <module>   s   