관리-도구
편집 파일: ipv6.cpython-36.opt-1.pyc
3 �b�W� � @ s� d Z ddlZddlZddlZddlZddlmZmZm Z ej d�Zdd� Zej d�Z ej d �Zej d �Zdd� ZdZdd� ZdS )zIPv6 helper functions.� N� )�xrange�binary_type�maybe_decodes 0+([0-9a-f]+)c C s� t | �dkrtd��tj| �}g }d}t |�}xJ||k rx|||d � }tj|�}|dk rd|jd�}|j|� |d7 }q0W d}d}d} d} xNtd�D ]B}|| d kr�| r�|}|| }||kr�| }|}d} q�| s�|} d } q�W | � r�d}|| }||k� r�| }|}|dk�r�|dk�rb|dk�s4|dk�rb|d d k�rb|dk�rDd} nd} | t j j| dd� � }n,dj|d|� �d dj||| d� � }n dj|�}t |�S )z�Convert a network format IPv6 address into text. @param address: the binary address @type address: string @rtype: string @raises ValueError: the address isn't 16 bytes long � z IPv6 addresses are 16 bytes longr � Nr F� � 0T� � s ffffs ::s ::ffff:� � :���)�len� ValueError�binasciiZhexlify� _leading_zero�match�group�appendr �dns�ipv4� inet_ntoa�joinr )�address�hex�chunks�i�l�chunk�mZ best_startZbest_len�startZ last_was_zero�endZcurrent_len�prefix� r$ �/usr/lib/python3.6/ipv6.pyr s^ r s (.*):(\d+\.\d+\.\d+\.\d+)$s ::.*s .*::$c C s� t | t�s| j� } | dkrd} tj| �}|dk rvttjj|j d���}d|j d�j � |d |d |d |d f j� } tj| �}|dk r�| dd� } ntj| �}|dk r�| dd� } | j d �}t|�}|d kr�tjj�d}g }x�|D ]�}|dk�r.|�r tjj�d }xftdd | d �D ]}|jd� �qW q�t|�} | dk�rHtjj�| dk�rbdd| | }|j|� q�W |d k �r�| �r�tjj�dj|�} y tj| �S tjtfk �r� tjj�Y nX dS )z�Convert a text format IPv6 address into network format. @param text: the textual address @type text: string @rtype: string @raises dns.exception.SyntaxError: the text was not properly formatted s ::s 0::N� z%s:%02x%02x:%02x%02xr r � r r F� Ts 0000r r r )� isinstancer �encode� _v4_endingr � bytearrayr r � inet_atonr �decode�_colon_colon_start�_colon_colon_end�splitr Z exception�SyntaxErrorr r r r Z unhexlify�Error� TypeError) �textr �br r Z seen_emptyZ canonical�cr Zlcr$ r$ r% r- b sR r- � � s ��c C s | j t�S )N)� startswith�_mapped_prefix)r r$ r$ r% � is_mapped� s r<