File: //lib/python3.9/site-packages/dns/__pycache__/e164.cpython-39.opt-1.pyc
a
�M�e� � @ s� d Z ddlmZmZmZ ddlZddlZddlZej �
d�Zefeeej j
ej j
d�dd�Zedfej j
eej j
eed �d
d�Zdeeeej j
ef eejj ejjd�d
d�ZdS )zDNS E.164 helpers.� )�Iterable�Optional�UnionNz
e164.arpa.)�text�origin�returnc C s, dd� | D �}|� � tjjd�|�|d�S )a� Convert an E.164 number in textual form into a Name object whose
value is the ENUM domain name for that number.
Non-digits in the text are ignored, i.e. "16505551212",
"+1.650.555.1212" and "1 (650) 555-1212" are all the same.
*text*, a ``str``, is an E.164 number in textual form.
*origin*, a ``dns.name.Name``, the domain in which the number
should be constructed. The default is ``e164.arpa.``.
Returns a ``dns.name.Name``.
c S s g | ]}|� � r|�qS � )�isdigit��.0�dr r �,/usr/lib/python3.9/site-packages/dns/e164.py�
<listcomp>/ � zfrom_e164.<locals>.<listcomp>�.)r )�reverse�dns�name� from_text�join)r r �partsr r r
� from_e164 s r T)r r �want_plus_prefixr c C sf |dur| � |�} dd� | jD �}t|�t| j�kr@tj�d��|�� d�|�}|r^d| }|�� S )a� Convert an ENUM domain name into an E.164 number.
Note that dnspython does not have any information about preferred
number formats within national numbering plans, so all numbers are
emitted as a simple string of digits, prefixed by a '+' (unless
*want_plus_prefix* is ``False``).
*name* is a ``dns.name.Name``, the ENUM domain name.
*origin* is a ``dns.name.Name``, a domain containing the ENUM
domain name. The name is relativized to this domain before being
converted to text. If ``None``, no relativization is done.
*want_plus_prefix* is a ``bool``. If True, add a '+' to the beginning of
the returned number.
Returns a ``str``.
Nc S s$ g | ]}|� � rt|�d kr|�qS )� )r �lenr
r r r
r N r zto_e164.<locals>.<listcomp>z$non-digit labels in ENUM domain namer � +) Z
relativize�labelsr r � exception�SyntaxErrorr r �decode)r r r Zdlabelsr r r r
�to_e1644 s
r )�number�domains�resolverr c C s� |du rt j�� }t j�� }|D ]l}t|t�r:t j�|�}t j� | |�}z|�
|d�W S t jjy� } z||7 }W Y d}~q d}~0 0 q |�dS )a~ Look for NAPTR RRs for the specified number in the specified domains.
e.g. lookup('16505551212', ['e164.dnspython.org.', 'e164.arpa.'])
*number*, a ``str`` is the number to look for.
*domains* is an iterable containing ``dns.name.Name`` values.
*resolver*, a ``dns.resolver.Resolver``, is the resolver to use. If
``None``, the default resolver is used.
NZNAPTR)r r# Zget_default_resolverZNXDOMAIN�
isinstance�strr r Ze164r �resolve)r! r"