AlkantarClanX12

Your IP : 3.138.125.86


Current Path : /proc/self/root/usr/lib/python3.6/site-packages/dns/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3.6/site-packages/dns/__pycache__/e164.cpython-36.pyc

3

�b�WK�@s\dZddlZddlZddlZddlmZejjd�Z	e	fdd�Z
e	dfd	d
�Zd
dd�ZdS)z�DNS 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.cCs,dd�|D�}|j�tjjdj|�|d�S)auConvert 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
    cSsg|]}|j�r|�qS�)�isdigit)�.0�drr�/usr/lib/python3.6/e164.py�
<listcomp>)szfrom_e164.<locals>.<listcomp>�.)�origin)�reverse�dns�name�	from_text�join)�textr�partsrrr�	from_e164s
rTcCsb|dk	r|j|�}dd�|jD�}t|�t|j�kr@tjjd��|j�dj|�}|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
    NcSs$g|]}|j�rt|�dkr|�qS)r)r�len)rrrrrr	;szto_e164.<locals>.<listcomp>z$non-digit labels in ENUM domain name��+)Z
relativizeZlabelsrr
Z	exception�SyntaxErrorrr)rrZwant_plus_prefixZdlabelsrrrr�to_e164.s

rcCs�|dkrtjj�}tjj�}xl|D]d}t|t�r<tjj|�}tjj	||�}y|j
|d�Stjjk
r�}z||7}WYdd}~Xq"Xq"W|�dS)z�Look for NAPTR RRs for the specified number in the specified domains.

    e.g. lookup('16505551212', ['e164.dnspython.org.', 'e164.arpa.'])
    NZNAPTR)r
�resolverZget_default_resolverZNXDOMAIN�
isinstancerrrZe164r�query)ZnumberZdomainsrZe_nxZdomainZqname�errrrEs



r)N)
�__doc__Z
dns.exceptionr
Zdns.nameZdns.resolverZ_compatrrrZpublic_enum_domainrrrrrrr�<module>s