AlkantarClanX12

Your IP : 18.223.206.84


Current Path : /proc/self/root/usr/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/__pycache__/ipaddress.cpython-36.opt-2.pyc

3

��f�/�@s�dZddlZdZdZGdd�de�ZGdd�de�Zd	d
�Zd<dd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�ZGd"d#�d#�ZejGd$d%�d%e��ZejGd&d'�d'e��ZGd(d)�d)�ZGd*d+�d+ee�ZGd,d-�d-e�ZGd.d/�d/ee�ZGd0d1�d1�Zee_Gd2d3�d3�ZGd4d5�d5ee�ZGd6d7�d7e�ZGd8d9�d9ee�Z Gd:d;�d;�Z!e!e_dS)=z1.0�N� �c@seZdZdS)�AddressValueErrorN)�__name__�
__module__�__qualname__�rr�!/usr/lib64/python3.6/ipaddress.pyrsrc@seZdZdS)�NetmaskValueErrorN)rrrrrrr	r
sr
cCsTyt|�Sttfk
r YnXyt|�Sttfk
rBYnXtd|��dS)Nz0%r does not appear to be an IPv4 or IPv6 address)�IPv4Addressrr
�IPv6Address�
ValueError)�addressrrr	�
ip_addresssrTcCsXy
t||�Sttfk
r"YnXy
t||�Sttfk
rFYnXtd|��dS)Nz0%r does not appear to be an IPv4 or IPv6 network)�IPv4Networkrr
�IPv6Networkr
)r�strictrrr	�
ip_network9s

rcCsTyt|�Sttfk
r YnXyt|�Sttfk
rBYnXtd|��dS)Nz2%r does not appear to be an IPv4 or IPv6 interface)�
IPv4Interfacerr
�
IPv6Interfacer
)rrrr	�ip_interfaceWsrcCs.y|jdd�Stk
r(td��YnXdS)N��bigz&Address negative or too large for IPv4)�to_bytes�
OverflowErrorr
)rrrr	�v4_int_to_packedzsrcCs.y|jdd�Stk
r(td��YnXdS)N�rz&Address negative or too large for IPv6)rrr
)rrrr	�v6_int_to_packed�s
rcCs*t|�jd�}t|�dkr&td|��|S)N�/�zOnly one '/' permitted in %r)�str�split�lenr)r�addrrrr	�_split_optional_netmask�sr$ccsRt|�}t|�}}x.|D]&}|j|jdkr<||fV|}|}qW||fVdS)N�)�iter�next�_ip)�	addresses�it�first�last�iprrr	�_find_address_range�s


r.cCs$|dkr|St|||d@j��S)Nrr%)�min�
bit_length)Znumber�bitsrrr	�_count_righthand_zero_bits�sr2ccs�t|t�ot|t�std��|j|jkr8td||f��||krHtd��|jdkrXt}n|jdkrht}ntd��|j}|j}|j}x^||kr�t	t
||�||dj�d�}||||f�}|V|d|>7}|d|jkr�Pq�WdS)Nz1first and last must be IP addresses, not networksz%%s and %s are not of the same versionz*last IP address must be greater than firstr�zunknown IP versionr%)
�
isinstance�_BaseAddress�	TypeError�versionr
rr�_max_prefixlenr(r/r2r0�	_ALL_ONES)r+r,r-Zip_bitsZ	first_intZlast_intZnbits�netrrr	�summarize_address_range�s0





r;ccs�t|�}i}xL|rX|j�}|j�}|j|�}|dkr>|||<q||kr||=|j|�qWd}x4t|j��D]$}|dk	r�|j|jkr�ql|V|}qlWdS)N)�list�pop�supernet�get�append�sorted�values�broadcast_address)r)Zto_merge�subnetsr:r>Zexistingr,rrr	�_collapse_addresses_internals$

rEcCs8g}g}g}x�|D]�}t|t�rT|rH|dj|jkrHtd||df��|j|�q|j|jkr�|r�|dj|jkr�td||df��y|j|j�Wq�tk
r�|j|j	�Yq�Xq|r�|dj|jkr�td||df��|j|�qWt
t|��}|�r,x&t|�D]\}}|j
t||���qWt||�S)	Nr%z%%s and %s are not of the same version���rFrFrFrFrF)r4r5�_versionr6r@�
_prefixlenr8r-�AttributeError�network_addressrA�setr.�extendr;rE)r)ZaddrsZipsZnetsr-r+r,rrr	�collapse_addresses2s4

rMcCs(t|t�r|j�St|t�r$|j�StS)N)r4�_BaseNetwork�_get_networks_keyr5�_get_address_key�NotImplemented)�objrrr	�get_mixed_type_keyhs


rSc@s�eZdZfZedd��Zedd��Zedd��Zedd��Zd	d
�Z	dd�Z
ed
d��Zedd��Z
edd��Zedd��Zedd��Zdd�ZdS)�_IPAddressBasecCs|j�S)N)�_explode_shorthand_ip_string)�selfrrr	�exploded�sz_IPAddressBase.explodedcCst|�S)N)r )rVrrr	�
compressed�sz_IPAddressBase.compressedcCs|j�S)N)�_reverse_pointer)rVrrr	�reverse_pointer�s	z_IPAddressBase.reverse_pointercCsdt|�f}t|��dS)Nz%200s has no version specified)�type�NotImplementedError)rV�msgrrr	r7�sz_IPAddressBase.versioncCsF|dkrd}t|||jf��||jkrBd}t|||j|jf��dS)Nrz-%d (< 0) is not permitted as an IPv%d addressz2%d (>= 2**%d) is not permitted as an IPv%d address)rrGr9r8)rVrr]rrr	�_check_int_address�s

z!_IPAddressBase._check_int_addresscCs.t|�}||kr*d}t|||||jf��dS)Nz6%r (len %d != %d) is not permitted as an IPv%d address)r"rrG)rVrZexpected_lenZaddress_lenr]rrr	�_check_packed_address�s
z$_IPAddressBase._check_packed_addresscCs|j|j|?AS)N)r9)�cls�	prefixlenrrr	�_ip_int_from_prefix�sz"_IPAddressBase._ip_int_from_prefixc	Cs\t||j�}|j|}||?}d|>d}||krX|jd}|j|d�}d}t||��|S)Nr%�rz&Netmask pattern %r mixes zeroes & ones)r2r8rr
)	r`�ip_intZtrailing_zeroesraZleading_onesZall_onesZbyteslenZdetailsr]rrr	�_prefix_from_ip_int�s


z"_IPAddressBase._prefix_from_ip_intcCsd|}t|�d�dS)Nz%r is not a valid netmask)r
)r`Znetmask_strr]rrr	�_report_invalid_netmask�sz&_IPAddressBase._report_invalid_netmaskcCsjtjj|�s|j|�yt|�}Wntk
r@|j|�YnXd|koV|jknsf|j|�|S)Nr)�_BaseV4�_DECIMAL_DIGITS�
issupersetrf�intr
r8)r`Z
prefixlen_strrarrr	�_prefix_from_prefix_string�s

z)_IPAddressBase._prefix_from_prefix_stringcCs�y|j|�}Wntk
r,|j|�YnXy
|j|�Stk
rLYnX||jN}y
|j|�Stk
r�|j|�YnXdS)N)�_ip_int_from_stringrrfrer
r9)r`�ip_strrdrrr	�_prefix_from_ip_string�s


z%_IPAddressBase._prefix_from_ip_stringcCs|jt|�ffS)N)�	__class__r )rVrrr	�
__reduce__sz_IPAddressBase.__reduce__N)rrr�	__slots__�propertyrWrXrZr7r^r_�classmethodrbrerfrkrnrprrrr	rT�s	
"rTc@s`eZdZfZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)r5cCs|jS)N)r()rVrrr	�__int__&sz_BaseAddress.__int__cCs2y|j|jko|j|jkStk
r,tSXdS)N)r(rGrIrQ)rV�otherrrr	�__eq__)s
z_BaseAddress.__eq__cCsFt|t�stS|j|jkr*td||f��|j|jkrB|j|jkSdS)Nz%%s and %s are not of the same versionF)r4r5rQrGr6r()rVrurrr	�__lt__0s
z_BaseAddress.__lt__cCs t|t�stS|jt|�|�S)N)r4rjrQro)rVrurrr	�__add__<s
z_BaseAddress.__add__cCs t|t�stS|jt|�|�S)N)r4rjrQro)rVrurrr	�__sub__As
z_BaseAddress.__sub__cCsd|jjt|�fS)Nz%s(%r))rorr )rVrrr	�__repr__Fsz_BaseAddress.__repr__cCst|j|j��S)N)r �_string_from_ip_intr()rVrrr	�__str__Isz_BaseAddress.__str__cCsttt|j���S)N)�hash�hexrjr()rVrrr	�__hash__Lsz_BaseAddress.__hash__cCs
|j|fS)N)rG)rVrrr	rPOsz_BaseAddress._get_address_keycCs|j|jffS)N)ror()rVrrr	rpRsz_BaseAddress.__reduce__N)rrrrqrtrvrwrxryrzr|rrPrprrrr	r5s	r5c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zed#d$��Zed%d&��Zd'd(�Zd)d*�Zd+d,�ZdAd/d0�ZdBd1d2�Zed3d4��Zed5d6��Zed7d8��Zed9d:��Zed;d<��Z ed=d>��Z!ed?d@��Z"d.S)CrNcCs
i|_dS)N)�_cache)rVrrrr	�__init___sz_BaseNetwork.__init__cCsd|jjt|�fS)Nz%s(%r))rorr )rVrrr	rzbsz_BaseNetwork.__repr__cCsd|j|jfS)Nz%s/%d)rJra)rVrrr	r|esz_BaseNetwork.__str__ccs<t|j�}t|j�}x"t|d|�D]}|j|�Vq$WdS)Nr%)rjrJrC�range�_address_class)rV�network�	broadcast�xrrr	�hostshs

z_BaseNetwork.hostsccs<t|j�}t|j�}x"t||d�D]}|j|�Vq$WdS)Nr%)rjrJrCr�r�)rVr�r�r�rrr	�__iter__ts

z_BaseNetwork.__iter__cCslt|j�}t|j�}|dkr>|||kr0td��|j||�S|d7}|||krZtd��|j||�SdS)Nrzaddress out of ranger%)rjrJrC�
IndexErrorr�)rV�nr�r�rrr	�__getitem__zs

z_BaseNetwork.__getitem__cCs^t|t�stS|j|jkr*td||f��|j|jkrB|j|jkS|j|jkrZ|j|jkSdS)Nz%%s and %s are not of the same versionF)r4rNrQrGr6rJ�netmask)rVrurrr	rw�s
z_BaseNetwork.__lt__cCsFy,|j|jko,|j|jko,t|j�t|j�kStk
r@tSXdS)N)rGrJrjr�rIrQ)rVrurrr	rv�sz_BaseNetwork.__eq__cCstt|j�t|j�A�S)N)r}rjrJr�)rVrrr	r�sz_BaseNetwork.__hash__cCsL|j|jkrdSt|t�rdSt|j�t|j�koBt|j�kSSdS)NF)rGr4rNrjrJr(rC)rVrurrr	�__contains__�s
z_BaseNetwork.__contains__cCs(|j|kp&|j|kp&|j|kp&|j|kS)N)rJrC)rVrurrr	�overlaps�s


z_BaseNetwork.overlapscCs<|jjd�}|dkr8|jt|j�t|j�B�}||jd<|S)NrC)r�r?r�rjrJ�hostmask)rVr�rrr	rC�s
z_BaseNetwork.broadcast_addresscCs8|jjd�}|dkr4|jt|j�|jA�}||jd<|S)Nr�)r�r?r�rjr�r9)rVr�rrr	r��s

z_BaseNetwork.hostmaskcCsd|j|jfS)Nz%s/%d)rJrH)rVrrr	�with_prefixlen�sz_BaseNetwork.with_prefixlencCsd|j|jfS)Nz%s/%s)rJr�)rVrrr	�with_netmask�sz_BaseNetwork.with_netmaskcCsd|j|jfS)Nz%s/%s)rJr�)rVrrr	�
with_hostmask�sz_BaseNetwork.with_hostmaskcCst|j�t|j�dS)Nr%)rjrCrJ)rVrrr	�
num_addresses�sz_BaseNetwork.num_addressescCsdt|�f}t|��dS)Nz%%200s has no associated address class)r[r\)rVr]rrr	r��sz_BaseNetwork._address_classcCs|jS)N)rH)rVrrr	ra�sz_BaseNetwork.prefixlenccsD|j|jkstd||f��t|t�s2td|��|j|jkoH|j|jksZtd||f��||krfdS|jd|j|jf�}|j	�\}}x�||ko�||k�r|j|jkr�|j|jkr�|V|j	�\}}q�|j|jkr�|j|jkr�|V|j	�\}}q�t
d|||f��q�W||k�r|Vn$||k�r.|Vnt
d|||f��dS)Nz%%s and %s are not of the same versionz%s is not a network objectz%s not contained in %sz%s/%sz3Error performing exclusion: s1: %s s2: %s other: %s)rGr6r4rNrJrCr
rorarD�AssertionError)rVru�s1�s2rrr	�address_exclude�s<$



z_BaseNetwork.address_excludecCs`|j|jkrtd||f��|j|jkr,dS|j|jkr<dS|j|jkrLdS|j|jkr\dSdS)Nz"%s and %s are not of the same typer%rrFrF)rGr6rJr�)rVrurrr	�compare_networks.s!z_BaseNetwork.compare_networkscCs|j|j|jfS)N)rGrJr�)rVrrr	rO^sz_BaseNetwork._get_networks_keyr%Nc	cs�|j|jkr|VdS|dk	rJ||jkr0td��|dkr@td��||j}|dkrZtd��|j|}||jkr~td||f��t|j�}t|j�d}t|j�d|?}x(t|||�D]}|j||f�}|Vq�WdS)Nznew prefix must be longerr%z(cannot set prefixlen_diff and new_prefixrzprefix length diff must be > 0z0prefix length diff %d is invalid for netblock %s)	rHr8r
rjrJrCr�r�ro)	rV�prefixlen_diff�
new_prefix�
new_prefixlen�start�end�stepZnew_addrZcurrentrrr	rDhs,




z_BaseNetwork.subnetscCs�|jdkr|S|dk	rB||jkr(td��|dkr8td��|j|}|j|}|dkrftd|j|f��|jt|j�t|j�|>@|f�S)Nrznew prefix must be shorterr%z(cannot set prefixlen_diff and new_prefixz;current prefixlen is %d, cannot have a prefixlen_diff of %d)rHr
rarorjrJr�)rVr�r�r�rrr	r>�s 



z_BaseNetwork.supernetcCs|jjo|jjS)N)rJ�is_multicastrC)rVrrr	r��s	z_BaseNetwork.is_multicastcCs|jjo|jjS)N)rJ�is_reservedrC)rVrrr	r��s	z_BaseNetwork.is_reservedcCs|jjo|jjS)N)rJ�
is_link_localrC)rVrrr	r��sz_BaseNetwork.is_link_localcCs|jjo|jjS)N)rJ�
is_privaterC)rVrrr	r��s	z_BaseNetwork.is_privatecCs|jS)N)r�)rVrrr	�	is_global�s	z_BaseNetwork.is_globalcCs|jjo|jjS)N)rJ�is_unspecifiedrC)rVrrr	r�s	z_BaseNetwork.is_unspecifiedcCs|jjo|jjS)N)rJ�is_loopbackrC)rVrrr	r�s	z_BaseNetwork.is_loopback)r%N)r%N)#rrrr�rzr|r�r�r�rwrvrr�r�rrrCr�r�r�r�r�r�rar�r�rOrDr>r�r�r�r�r�r�r�rrrr	rNVs>	

	N0

5
)rNc
@s�eZdZfZdZdedZed�Zeddddd	d
ddd
h	�Z	eZ
iZdd�Ze
dd��Ze
dd��Ze
dd��Ze
dd��Zdd�Zdd�Zdd�Zedd��Zed d!��Zd"S)#rgrrr%�
0123456789���������rrcCst|�S)N)r )rVrrr	rU0sz$_BaseV4._explode_shorthand_ip_stringcCsn||jkrdt|t�r|}n.y|j|�}Wntk
rF|j|�}YnXt|j|��}||f|j|<|j|S)N)�_netmask_cacher4rjrkr
rnrrb)r`�argrar�rrr	�
_make_netmask3s	

z_BaseV4._make_netmaskcCs||std��|jd�}t|�dkr.td|��ytjt|j|�d�Stk
rv}ztd||f�d�WYdd}~XnXdS)NzAddress cannot be empty�.rzExpected 4 octets in %rrz%s in %r)rr!r"rj�
from_bytes�map�_parse_octetr
)r`rmZoctets�excrrr	rlKs
z_BaseV4._ip_int_from_stringcCs�|std��|jj|�s(d}t||��t|�dkrDd}t||��t|d�}|dkrr|ddkrrd	}t||��|d
kr�td|��|S)NzEmpty octet not permittedz#Only decimal digits permitted in %r�z$At most 3 characters permitted in %r�
�r�0z3Ambiguous (octal/decimal) value in %r not permittedr�zOctet %d (> 255) not permitted)r
rhrir"rj)r`Z	octet_strr]Z	octet_intrrr	r�es
z_BaseV4._parse_octetcCsdjtt|jdd���S)Nr�rr)�joinr�r r)r`rdrrr	r{�sz_BaseV4._string_from_ip_intcCs�|jd�}t|�dkr�y$x|D]}t|�|jkrdSqWWntk
rNdSXx0t|�D]$\}}|dkrZ|||dkrZdSqZWdSyt|�}Wntk
r�dSXd|ko�|jkSS)Nr�rFrr%T)r!r"rj�_valid_mask_octetsr
�	enumerater8)rVr��maskr��idx�yrrr	�_is_valid_netmask�s"

z_BaseV4._is_valid_netmaskcsh|jd�}y�fdd�tt|�D�}Wntk
r:dSXt|�t|�krPdS|d|dkrddSdS)	Nr�csg|]}|�jkr|�qSr)r�)�.0r�)rVrr	�
<listcomp>�sz(_BaseV4._is_hostmask.<locals>.<listcomp>Frr%TrF)r!r�rjr
r")rVrmr1�partsr)rVr	�_is_hostmask�s

z_BaseV4._is_hostmaskcCs&t|�jd�ddd�}dj|�dS)Nr�r%z
.in-addr.arparF)r r!r�)rVZreverse_octetsrrr	rY�sz_BaseV4._reverse_pointercCs|jS)N)r8)rVrrr	�
max_prefixlen�sz_BaseV4.max_prefixlencCs|jS)N)rG)rVrrr	r7�sz_BaseV4.versionN)rrrrqrG�
IPV4LENGTHr9�	frozensetrhr�r8r�rUrsr�rlr�r{r�r�rYrrr�r7rrrr	rgs"	%
	rgc@s�eZdZdZdd�Zedd��Zedd��Zeej	�d	d
���Z
eej	�dd���Zed
d��Zedd��Z
edd��Zedd��ZdS)rr(�__weakref__cCsrt|t�r|j|�||_dSt|t�rF|j|d�tj|d�|_dSt|�}d|krbtd|��|j	|�|_dS)NrrrzUnexpected '/' in %r)
r4rjr^r(�bytesr_r�r rrl)rVr�addr_strrrr	r��s


zIPv4Address.__init__cCs
t|j�S)N)rr()rVrrr	�packedszIPv4Address.packedcCs||jjkS)N)�
_constants�_reserved_network)rVrrr	r�s	zIPv4Address.is_reservedcs4t�fdd��jjD��o2t�fdd��jjD��S)Nc3s|]}�|kVqdS)Nr)r�r:)rVrr	�	<genexpr>(sz)IPv4Address.is_private.<locals>.<genexpr>c3s|]}�|kVqdS)Nr)r�r:)rVrr	r�)s)�anyr��_private_networks�all�_private_networks_exceptions)rVr)rVr	r�szIPv4Address.is_privatecCs||jjko|jS)N)r��_public_networkr�)rVrrr	r�,szIPv4Address.is_globalcCs||jjkS)N)r��_multicast_network)rVrrr	r�>s	zIPv4Address.is_multicastcCs||jjkS)N)r��_unspecified_address)rVrrr	r�Is	zIPv4Address.is_unspecifiedcCs||jjkS)N)r��_loopback_network)rVrrr	r�TszIPv4Address.is_loopbackcCs||jjkS)N)r��_linklocal_network)rVrrr	r�^szIPv4Address.is_link_localN)r(r�)rrrrqr�rrr�r��	functools�	lru_cacher�r�r�r�r�r�rrrr	r�s#
rc@sjeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	Z	e
dd��Ze
d
d��Ze
dd��Z
e
dd��ZdS)rcCs�t|ttf�r2tj||�t|j�|_|j|_	dSt|t
�r�tj||d�t|�dkrht|d�|_	n|j|_	t|dd�|_|jj|_|jj
|_
dSt|�}tj||d�t|dd�|_|jj	|_	|jj|_|jj
|_
dS)Nrr%F)r)r4r�rjrr�rr(r�r8rH�tupler"r�r�r$)rVrr#rrr	r�ks(




zIPv4Interface.__init__cCsd|j|j�|jjfS)Nz%s/%d)r{r(r�ra)rVrrr	r|�szIPv4Interface.__str__cCsDtj||�}|s|tkr|Sy|j|jkStk
r>dSXdS)NF)rrvrQr�rI)rVru�
address_equalrrr	rv�szIPv4Interface.__eq__cCsNtj||�}|tkrtSy|j|jkp4|j|jko4|Stk
rHdSXdS)NF)rrwrQr�rI)rVru�address_lessrrr	rw�szIPv4Interface.__lt__cCst|j|jt|jj�f�S)N)r}r(rHrjr�rJ)rVrrr	r�szIPv4Interface.__hash__cCs
t|j�S)N)rr()rVrrr	r-�szIPv4Interface.ipcCsd|j|j�|jfS)Nz%s/%s)r{r(rH)rVrrr	r��szIPv4Interface.with_prefixlencCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r��szIPv4Interface.with_netmaskcCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r��szIPv4Interface.with_hostmaskN)rrrr�r|rvrwrrTrprrr-r�r�r�rrrr	risrc@s.eZdZeZddd�Zeej�dd���Z	dS)rTcCs�tj||�t|ttf�r&|}|j}n^t|t�rT|d}t|�dkrL|dn|j}n0t|�}|j	|d�}t|�dkr~|dn|j}t
|�|_|j|�\|_
|_t|j�}|t|j
�@|kr�|r�td|��nt
|t|j
�@�|_|j|jdkr�|j|_dS)Nrr%rz%s has host bits set)rNr�r4rjr�r8r�r"r$rlrrJr�r�rHr
r�r�)rVrrr#r��argsr�rrr	r��s(%


zIPv4Network.__init__cCs&|jtd�ko|jtd�ko$|jS)Nz
100.64.0.0/10)rJrrCr�)rVrrr	r�s
zIPv4Network.is_globalN)T)
rrrrr�r�rrr�r�r�rrrr	r�s

Crc@s�eZdZed�Zed�Zed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�ed
�ed�ed�ed�gZed�ed�gZ	ed�Z
ed�ZdS)�_IPv4Constantsz169.254.0.0/16z127.0.0.0/8z224.0.0.0/4z
100.64.0.0/10z	0.0.0.0/8z
10.0.0.0/8z
172.16.0.0/12z192.0.0.0/24z192.0.0.170/31z192.0.2.0/24z192.168.0.0/16z
198.18.0.0/15z198.51.100.0/24z203.0.113.0/24z240.0.0.0/4z255.255.255.255/32z192.0.0.9/32z
192.0.0.10/32z0.0.0.0N)
rrrrr�r�r�r�r�r�r�rr�rrrr	r�s,

r�c@s�eZdZfZdZdedZdZed�Z	eZ
iZedd��Z
edd	��Zed
d��Zedd
��Zeddd��Zdd�Zdd�Zedd��Zedd��ZdS)�_BaseV6r3rr%rcZ0123456789ABCDEFabcdefcCsJ||jkr@t|t�r|}n
|j|�}t|j|��}||f|j|<|j|S)N)r�r4rjrkrrb)r`r�rar�rrr	r�Zs	


z_BaseV6._make_netmaskcCs�|std��|jd�}d}t|�|kr:d||f}t|��d|dkr�yt|j��j}Wn4tk
r�}ztd||f�d�WYdd}~XnX|jd|d	?d
@�|jd|d
@�|jd}t|�|kr�d|d|f}t|��d}xDtdt|�d�D].}	||	�s�|dk	�r$d|}t|��|	}�q�W|dk	�r�|}
t|�|d}|d
�st|
d8}
|
�rtd}t||��|d�s�|d8}|�r�d}t||��|j|
|}|dk�r:d}t||jd|f��njt|�|jk�r�d}t||j|f��|d
�sd}t||��|d�s*d}t||��t|�}
d
}d
}ytd
}
x,t|
�D] }	|
d	K}
|
|j	||	�O}
�qJW|
d	|K}
x0t|d
�D] }	|
d	K}
|
|j	||	�O}
�q�W|
St
k
�r�}ztd||f�d�WYdd}~XnXdS)NzAddress cannot be empty�:r�z At least %d parts expected in %rr�r%z%s in %rz%xri��z!At most %d colons permitted in %rz At most one '::' permitted in %rrz0Leading ':' only permitted as part of '::' in %rz1Trailing ':' only permitted as part of '::' in %rz/Expected at most %d other parts with '::' in %rz,Exactly %d parts expected without '::' in %rrFrFrF)rr!r"rr=r(r@�
_HEXTET_COUNTr��
_parse_hextetr
)r`rmr�Z
_min_partsr]Zipv4_intr�Z
_max_partsZ
skip_index�iZparts_hiZparts_loZ
parts_skippedrdrrr	rlls�
$









z_BaseV6._ip_int_from_stringcCs>|jj|�std|��t|�dkr4d}t||��t|d�S)NzOnly hex digits permitted in %rrz$At most 4 characters permitted in %rr)�_HEX_DIGITSrir
r"rj)r`Z
hextet_strr]rrr	r��sz_BaseV6._parse_hextetc	Cs�d}d}d}d}xJt|�D]>\}}|dkrP|d7}|dkr>|}||krX|}|}qd}d}qW|dkr�||}|t|�kr�|dg7}dg|||�<|dkr�dg|}|S)	Nr%rr��rFrFrFrF)r�r")	r`�hextetsZbest_doublecolon_startZbest_doublecolon_lenZdoublecolon_startZdoublecolon_len�indexZhextetZbest_doublecolon_endrrr	�_compress_hextets�s.

z_BaseV6._compress_hextetsNcsZ|dkrt|j�}||jkr$td��d|��fdd�tddd�D�}|j|�}dj|�S)	NzIPv6 address is too largez%032xcs&g|]}dt�||d�d��qS)z%xrr)rj)r�r�)�hex_strrr	r�3sz/_BaseV6._string_from_ip_int.<locals>.<listcomp>rrrr�)rjr(r9r
r�r�r�)r`rdr�r)r�r	r{s


z_BaseV6._string_from_ip_intcs�t|t�rt|j�}nt|t�r,t|j�}nt|�}|j|�}d|��fdd�tddd�D�}t|ttf�r�ddj	|�|j
fSdj	|�S)	Nz%032xcsg|]}�||d��qS)rr)r�r�)r�rr	r�Ksz8_BaseV6._explode_shorthand_ip_string.<locals>.<listcomp>rrrz%s/%dr�)r4rr rJrr-rlr�rNr�rH)rVrmrdr�r)r�r	rU8s



z$_BaseV6._explode_shorthand_ip_stringcCs&|jddd�jdd�}dj|�dS)Nr%r�r�r�z	.ip6.arparF)rW�replacer�)rVZ
reverse_charsrrr	rYPsz_BaseV6._reverse_pointercCs|jS)N)r8)rVrrr	r�Ysz_BaseV6.max_prefixlencCs|jS)N)rG)rVrrr	r7]sz_BaseV6.version)N)rrrrqrG�
IPV6LENGTHr9r�r�r�r8r�rsr�rlr�r�r{rUrYrrr�r7rrrr	r�Fs"	h0	r�c@s�eZdZdZdd�Zedd��Zedd��Zed	d
��Zedd��Z	ed
d��Z
eej�dd���Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��ZdS)rr(r�cCsrt|t�r|j|�||_dSt|t�rF|j|d�tj|d�|_dSt|�}d|krbtd|��|j	|�|_dS)NrrrzUnexpected '/' in %r)
r4rjr^r(r�r_r�r rrl)rVrr�rrr	r�hs


zIPv6Address.__init__cCs
t|j�S)N)rr()rVrrr	r��szIPv6Address.packedcCs||jjkS)N)r�r�)rVrrr	r��s	zIPv6Address.is_multicastcst�fdd��jjD��S)Nc3s|]}�|kVqdS)Nr)r�r�)rVrr	r��sz*IPv6Address.is_reserved.<locals>.<genexpr>)r�r��_reserved_networks)rVr)rVr	r��s	zIPv6Address.is_reservedcCs||jjkS)N)r�r�)rVrrr	r��szIPv6Address.is_link_localcCs||jjkS)N)r��_sitelocal_network)rVrrr	�
is_site_local�szIPv6Address.is_site_localcsH�j}|dk	r|jSt�fdd��jjD��oFt�fdd��jjD��S)Nc3s|]}�|kVqdS)Nr)r�r:)rVrr	r��sz)IPv6Address.is_private.<locals>.<genexpr>c3s|]}�|kVqdS)Nr)r�r:)rVrr	r��s)�ipv4_mappedr�r�r�r�r�r�)rVr�r)rVr	r��s
zIPv6Address.is_privatecCs|jS)N)r�)rVrrr	r��szIPv6Address.is_globalcCs
|jdkS)Nr)r()rVrrr	r��s	zIPv6Address.is_unspecifiedcCs
|jdkS)Nr%)r()rVrrr	r��s	zIPv6Address.is_loopbackcCs |jd?dkrdSt|jd@�S)Nri��l��)r(r)rVrrr	r��s	zIPv6Address.ipv4_mappedcCs4|jd?dkrdSt|jd?d@�t|jd@�fS)N�`i �@l��)r(r)rVrrr	�teredos
zIPv6Address.teredocCs$|jd?dkrdSt|jd?d@�S)N�pi �Pl��)r(r)rVrrr	�	sixtofours	zIPv6Address.sixtofourN)r(r�)rrrrqr�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rbs$

rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	Z	e
dd��Ze
d
d��Ze
dd��Z
e
dd��Ze
dd��Ze
dd��ZdS)rcCs�t|ttf�r2tj||�t|j�|_|j|_	dSt|t
�r�tj||d�t|�dkrht|d�|_	n|j|_	t|dd�|_|jj|_|jj
|_
dSt|�}tj||d�t|dd�|_|jj|_|jj	|_	|jj
|_
dS)Nrr%F)r)r4r�rjrr�rr(r�r8rHr�r"r�r�r$)rVrr#rrr	r�+s(




zIPv6Interface.__init__cCsd|j|j�|jjfS)Nz%s/%d)r{r(r�ra)rVrrr	r|CszIPv6Interface.__str__cCsDtj||�}|s|tkr|Sy|j|jkStk
r>dSXdS)NF)rrvrQr�rI)rVrur�rrr	rvGszIPv6Interface.__eq__cCsNtj||�}|tkrtSy|j|jkp4|j|jko4|Stk
rHdSXdS)NF)rrwrQr�rI)rVrur�rrr	rwSszIPv6Interface.__lt__cCst|j|jt|jj�f�S)N)r}r(rHrjr�rJ)rVrrr	r_szIPv6Interface.__hash__cCs
t|j�S)N)rr()rVrrr	r-dszIPv6Interface.ipcCsd|j|j�|jfS)Nz%s/%s)r{r(rH)rVrrr	r�hszIPv6Interface.with_prefixlencCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r�mszIPv6Interface.with_netmaskcCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r�rszIPv6Interface.with_hostmaskcCs|jdko|jjS)Nr)r(r�r�)rVrrr	r�wszIPv6Interface.is_unspecifiedcCs|jdko|jjS)Nr%)r(r�r�)rVrrr	r�{szIPv6Interface.is_loopbackN)rrrr�r|rvrwrrTrprrr-r�r�r�r�r�rrrr	r)src@s.eZdZeZd	dd�Zdd�Zedd��ZdS)
rTcCs�tj||�t|ttf�r&|}|j}n^t|t�rT|d}t|�dkrL|dn|j}n0t|�}|j	|d�}t|�dkr~|dn|j}t
|�|_|j|�\|_
|_t|j�}|t|j
�@|kr�|r�td|��nt
|t|j
�@�|_|j|jdkr�|j|_dS)Nrr%rz%s has host bits set)rNr�r4rjr�r8r�r"r$rlrrJr�r�rHr
r�r�)rVrrr#r�r�r�rrr	r��s( 


zIPv6Network.__init__ccs@t|j�}t|j�}x&t|d|d�D]}|j|�Vq(WdS)Nr%)rjrJrCr�r�)rVr�r�r�rrr	r��s

zIPv6Network.hostscCs|jjo|jjS)N)rJr�rC)rVrrr	r��szIPv6Network.is_site_localN)T)	rrrrr�r�r�rrr�rrrr	r�s
>rc@s�eZdZed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�g
Zed�ed
�ed�ed�ed�ed�gZed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed �gZed!�Z	d"S)#�_IPv6Constantsz	fe80::/10zff00::/8z::1/128z::/128z
::ffff:0:0/96z64:ff9b:1::/48z100::/64z	2001::/23z
2001:db8::/32z	2002::/16zfc00::/7z
2001:1::1/128z
2001:1::2/128z2001:3::/32z2001:4:112::/48z2001:20::/28z2001:30::/28z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9z	fec0::/10N)
rrrrr�r�r�r�r�r�rrrr	r��s6


r�)T)"�__version__r�r�r�r
rr
rrrrrr$r.r2r;rErMrSrT�total_orderingr5rNrgrrrr�r�r�rrrr�rrrr	�<module>sV
#716:EE
Sa&HWj-