AlkantarClanX12

Your IP : 3.142.172.190


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/ipaddress.cpython-35.opt-2.pyc



���]�'�@s dZddlZdZdZGdd�de�ZGdd�de�Zd	d
�Zdd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@seZdZdS)�AddressValueErrorN)�__name__�
__module__�__qualname__�rr�./opt/alt/python35/lib64/python3.5/ipaddress.pyrsrc@seZdZdS)�NetmaskValueErrorN)rrrrrrr	r
sr
cCsfyt|�SWnttfk
r(YnXyt|�SWnttfk
rQYnXtd|��dS)Nz0%r does not appear to be an IPv4 or IPv6 address)�IPv4Addressrr
�IPv6Address�
ValueError)�addressrrr	�
ip_addresssrTcCslyt||�SWnttfk
r+YnXyt||�SWnttfk
rWYnXtd|��dS)Nz0%r does not appear to be an IPv4 or IPv6 network)�IPv4Networkrr
�IPv6Networkr
)r�strictrrr	�
ip_network9srcCsfyt|�SWnttfk
r(YnXyt|�SWnttfk
rQYnXtd|��dS)Nz2%r does not appear to be an IPv4 or IPv6 interface)�
IPv4Interfacerr
�
IPv6Interfacer
)rrrr	�ip_interfaceWsrcCs9y|jdd�SWntk
r4td��YnXdS)N��bigz&Address negative or too large for IPv4)�to_bytes�
OverflowErrorr
)rrrr	�v4_int_to_packedzs
rcCs9y|jdd�SWntk
r4td��YnXdS)N�rz&Address negative or too large for IPv6)rrr
)rrrr	�v6_int_to_packed�s

rcCs;t|�jd�}t|�dkr7td|��|S)N�/�zOnly one '/' permitted in %r)�str�split�lenr)r�addrrrr	�_split_optional_netmask�sr$ccsit|�}t|�}}x;|D]3}|j|jdkrP||fV|}|}q#W||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�sr2ccs?t|t�ot|t�s*td��|j|jkrRtd||f��||krjtd��|jdkr�t}n$|jdkr�t}ntd��|j}|j}|j}xw||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}xj|r~|j�}|j�}|j|�}|dkr[|||<q||kr||=|j|�qWd}xFt|j��D]2}|dk	r�|j|jkr�q�|V|}q�WdS)N)�list�pop�supernet�get�append�sorted�values�broadcast_address)r)Zto_merge�subnetsr:r>Zexistingr,rrr	�_collapse_addresses_internals$	
rEcCs�g}g}g}x*|D]"}t|t�rt|rd|dj|jkrdtd||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�x0t|�D]"\}}|j
t||��qdWt||�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

rMcCs6t|t�r|j�St|t�r2|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.explodedcCs
t|�S)N)r )rVrrr	�
compressed�sz_IPAddressBase.compressedcCs
|j�S)N)�_reverse_pointer)rVrrr	�reverse_pointer�s	z_IPAddressBase.reverse_pointercCs#dt|�f}t|��dS)Nz%200s has no version specified)�type�NotImplementedError)rV�msgrrr	r7�sz_IPAddressBase.versioncCsc|dkr+d}t|||jf��||jkr_d}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_addresscCsAt|�}||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�s
z&_IPAddressBase._report_invalid_netmaskcCs�tjj|�s|j|�yt|�}Wntk
rP|j|�YnXd|kok|jkns}|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
r4|j|�YnXy|j|�SWntk
rZYnX||jN}y|j|�SWntk
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__cCsCy&|j|jko$|j|jkSWntk
r>tSYnXdS)N)r(rGrIrQ)rV�otherrrr	�__eq__)s

z_BaseAddress.__eq__cCsat|t�stS|j|jkr;td||f��|j|jkr]|j|jkSdS)Nz%%s and %s are not of the same versionF)r4r5rQrGr6r()rVrurrr	�__lt__0sz_BaseAddress.__lt__cCs*t|t�stS|jt|�|�S)N)r4rjrQro)rVrurrr	�__add__<sz_BaseAddress.__add__cCs*t|t�stS|jt|�|�S)N)r4rjrQro)rVrurrr	�__sub__Asz_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@s�eZdZdd�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,�Zd-d.d/d0�Zd-d.d1d2�Zed3d4��Zed5d6��Zed7d8��Zed9d:��Zed;d<��Z ed=d>��Z!ed?d@��Z"d.S)ArNcCs
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__ccsNt|j�}t|j�}x)t|d|�D]}|j|�Vq2WdS)Nr%)rjrJrC�range�_address_class)rV�network�	broadcast�xrrr	�hostshsz_BaseNetwork.hostsccsNt|j�}t|j�}x)t||d�D]}|j|�Vq2WdS)Nr%)rjrJrCr�r�)rVr�r�r�rrr	�__iter__tsz_BaseNetwork.__iter__cCs�t|j�}t|j�}|dkrQ|||kr@t�|j||�S|d7}|||krqt�|j||�SdS)Nrr%)rjrJrC�
IndexErrorr�)rV�nr�r�rrr	�__getitem__zs
z_BaseNetwork.__getitem__cCs�t|t�stS|j|jkr;td||f��|j|jkr]|j|jkS|j|jkr|j|jkSdS)Nz%%s and %s are not of the same versionF)r4rNrQrGr6rJ�netmask)rVrurrr	rw�sz_BaseNetwork.__lt__cCsayD|j|jkoB|j|jkoBt|j�t|j�kSWntk
r\tSYnXdS)N)rGrJrjr�rIrQ)rVrurrr	rv�s 
z_BaseNetwork.__eq__cCs tt|j�t|j�A�S)N)r}rjrJr�)rVrrr	r�sz_BaseNetwork.__hash__cCs`|j|jkrdSt|t�r)dSt|j�t|j�koYt|j�kSSdS)NF)rGr4rNrjrJr(rC)rVrurrr	�__contains__�s z_BaseNetwork.__contains__cCs:|j|kp9|j|kp9|j|kp9|j|kS)N)rJrC)rVrurrr	�overlaps�sz_BaseNetwork.overlapscCsT|jjd�}|dkrP|jt|j�t|j�B�}||jd<|S)NrC)r�r?r�rjrJ�hostmask)rVr�rrr	rC�s
z_BaseNetwork.broadcast_addresscCsN|jjd�}|dkrJ|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_addressescCs#dt|�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.prefixlenccs�|j|jks(td||f��t|t�sGtd|��|j|jkoh|j|jks�td||f��||kr�dS|jd|j|jf�}|j	�\}}x�||kru||kru|j|jkr|j|jkr|V|j	�\}}q�|j|jkrY|j|jkrY|V|j	�\}}q�t
d|||f��q�W||kr�|Vn-||kr�|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|jkr(td||f��|j|jkr>dS|j|jkrTdS|j|jkrjdS|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	rg||jkrBtd��|dkrZtd��||j}|dkrtd��|j|}||jkr�td||f��t|j�}t|j�d}t|j�d|?}x4t|||�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_addr�currentrrr	rDhs,

z_BaseNetwork.subnetscCs�|jdkr|S|dk	r_||jkr:td��|dkrRtd��|j|}|j|}|dkr�td|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��sz_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)#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>	

	N0
5)rNc
@seZdZfZdZdedZed�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���������rrcCs
t|�S)N)r )rVrrr	rU0sz$_BaseV4._explode_shorthand_ip_stringcCs�||jkr�t|t�r'|}n7y|j|�}Wn!tk
r]|j|�}YnXt|j|��}||f|j|<|j|S)N)�_netmask_cacher4rjrkr
rnrrb)r`�argrar�rrr	�
_make_netmask3s		
z_BaseV4._make_netmaskcCs�|std��|jd�}t|�dkrCtd|��y tjt|j|�d�SWn>tk
r�}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�|std��|jj|�s:d}t||��t|�dkrbd}t||��t|d�}|dkr�|ddkr�d	}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_octetcCs"djtt|jdd���S)Nr�rr)�joinr�r r)r`rdrrr	r{�sz_BaseV4._string_from_ip_intcCs�|jd�}t|�dkr�y.x'|D]}t|�|jkr+dSq+WWntk
rgdSYnXx>t|�D]0\}}|dkru|||dkrudSquWdSyt|�}Wntk
r�dSYnXd|ko�|jkSS)Nr�rFrr%T)r!r"rj�_valid_mask_octetsr
�	enumerater8)rVr��maskr��idx�yrrr	�_is_valid_netmask�s"

	 
	z_BaseV4._is_valid_netmaskcs�|jd�}y&�fdd�tt|�D�}Wntk
rMdSYnXt|�t|�krjdS|d|dkr�dSdS)	Nr�cs%g|]}|�jkr|�qSr)r�)�.0r�)rVrr	�
<listcomp>�s	z(_BaseV4._is_hostmask.<locals>.<listcomp>Frr%TrF)r!r�rjr
r")rVrmr1�partsr)rVr	�_is_hostmask�s
&
	z_BaseV4._is_hostmaskcCs3t|�jd�ddd�}dj|�dS)Nr�r%z
.in-addr.arparF)r r!r�)rVZreverse_octetsrrr	rY�s"z_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__cCs�t|t�r)|j|�||_dSt|t�ra|j|d�tj|d�|_dSt|�}d|kr�td|��|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_reservedcs#t�fdd��jjD��S)Nc3s|]}�|kVqdS)Nr)r�r:)rVrr	�	<genexpr> sz)IPv4Address.is_private.<locals>.<genexpr>)�anyr��_private_networks)rVr)rVr	r�s
zIPv4Address.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�2s	zIPv4Address.is_unspecifiedcCs||jjkS)N)r��_loopback_network)rVrrr	r�=szIPv4Address.is_loopbackcCs||jjkS)N)r��_linklocal_network)rVrrr	r�GszIPv4Address.is_link_localN)r(r�)rrrrqr�rrr�r��	functools�	lru_cacher�r�r�r�r�r�rrrr	r�s#
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	Z	e
dd��Ze
d
d��Ze
dd��Z
e
dd��ZdS)rcCs;t|ttf�rGtj||�t|j�|_|j|_	dSt|t
�r�tj||d�t|�dkr�t|d�|_	n|j|_	t|dd�|_|jj|_|jj
|_
dSt|�}tj||d�t|dd�|_|jj	|_	|jj|_|jj
|_
dS)Nrr%rF)r4r�rjrr�rr(r�r8rH�tupler"r�r�r$)rVrr#rrr	r�Ts(zIPv4Interface.__init__cCs d|j|j�|jjfS)Nz%s/%d)r{r(r�ra)rVrrr	r|pszIPv4Interface.__str__cCsZtj||�}|s%|tkr)|Sy|j|jkSWntk
rUdSYnXdS)NF)rrvrQr�rI)rVru�
address_equalrrr	rvts
zIPv4Interface.__eq__cCsktj||�}|tkr"tSy,|j|jkpL|j|jkoL|SWntk
rfdSYnXdS)NF)rrwrQr�rI)rVru�address_lessrrr	rw�s
zIPv4Interface.__lt__cCs|j|jAt|jj�AS)N)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��szIPv4Interface.with_prefixlencCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r��szIPv4Interface.with_netmaskcCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r��szIPv4Interface.with_hostmaskN)rrrr�r|rvrwrrTrprrr-r�r�r�rrrr	rRs	rc@sCeZdZeZddd�Zeej�dd���Z	dS)rTcCstj||�t|ttf�rVt|�|_|j|j�\|_	|_
dSt|t�rt|�dkr�|d}n	|j}t|d�|_|j|�\|_	|_
t|j�}|t|j	�@|kr|r�t
d|��nt|t|j	�@�|_dSt|�}t|j|d��|_t|�dkrc|d}n	|j}|j|�\|_	|_
|r�tt|j�t|j	�@�|jkr�t
d|��tt|j�t|j	�@�|_|j
|jdkr|j|_dS)Nr%rz%s has host bits setr)rNr�r4rjr�rrJr�r8r�rHr�r"r
r$rlr�r�)rVrrr�r�r#rrr	r��s@%
	
	zIPv4Network.__init__cCs3|jtd�ko'|jtd�ko2|jS)Nz
100.64.0.0/10)rJrrCr�)rVrrr	r�s
zIPv4Network.is_globalN)
rrrrr�r�rrr�r�r�rrrr	r�s
Trc@s�eZdZed�Zed�Zed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�ed
�ed�ed�ed�gZed�Z	e
d�ZdS)�_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/29z192.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/32z0.0.0.0N)rrrrr�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%rcZ0123456789ABCDEFabcdefcCsi||jkr^t|t�r'|}n|j|�}t|j|��}||f|j|<|j|S)N)r�r4rjrkrrb)r`r�rar�rrr	r�Ms		z_BaseV6._make_netmaskcCs�|std��|jd�}d}t|�|krUd||f}t|��d|dkr�yt|j��j}Wn>tk
r�}ztd||f�d�WYdd}~XnX|jd|d	?d
@�|jd|d
@�|jd}t|�|kr,d|d|f}t|��d}xStdt|�d�D]8}	||	sL|dk	r~d|}t|��|	}qLW|dk	rQ|}
t|�|d}|d
s�|
d8}
|
r�d}t||��|ds|d8}|rd}t||��|j|
|}|dkr�d}t||jd|f��n�t|�|jkr�d}t||j|f��|d
s�d}t||��|ds�d}t||��t|�}
d
}d
}y�d
}
x5t|
�D]'}	|
d	K}
|
|j	||	�O}
q�W|
d	|K}
x9t|d
�D]'}	|
d	K}
|
|j	||	�O}
q=W|
SWn>t
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	rl_s�,
 






 



z_BaseV6._ip_int_from_stringcCsW|jj|�s"td|��t|�dkrJd}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}xit|�D][\}}|dkrt|d7}|dkrY|}||kr�|}|}q%d}d}q%W|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_hextetsNcs�|dkrt|j�}||jkr6td��d|��fdd�tddd�D�}|j|�}dj|�S)	NzIPv6 address is too largez%032xcs1g|]'}dt�||d�d��qS)z%xrr)rj)r�r�)�hex_strrr	r�&s	z/_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�r!t|j�}n-t|t�rBt|j�}nt|�}|j|�}d|��fdd�tddd�D�}t|ttf�r�ddj	|�|j
fSdj	|�S)	Nz%032xcs$g|]}�||d��qS)rr)r�r�)r�rr	r�>s	z8_BaseV6._explode_shorthand_ip_string.<locals>.<listcomp>rrrz%s/%dr�)r4rr rJrr-rlr�rNr�rH)rVrmrdr�r)r�r	rU+s

%z$_BaseV6._explode_shorthand_ip_stringcCs3|jddd�jdd�}dj|�dS)Nr%r�r�r�z	.ip6.arparF)rW�replacer�)rVZ
reverse_charsrrr	rYCs"z_BaseV6._reverse_pointercCs|jS)N)r8)rVrrr	r�Lsz_BaseV6.max_prefixlencCs|jS)N)rG)rVrrr	r7Psz_BaseV6.version)rrrrqrG�
IPV6LENGTHr9r�r�r�r8r�rsr�rlr�r�r{rUrYrrr�r7rrrr	r�9s"	h0	r�c@seZdZdZdd�Zedd��Zedd��Zed	d
��Zedd��Z	ed
d��Z
eej�dd���Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��ZdS)rr(r�cCs�t|t�r)|j|�||_dSt|t�ra|j|d�tj|d�|_dSt|�}d|kr�td|��|j	|�|_dS)NrrrzUnexpected '/' in %r)
r4rjr^r(r�r_r�r rrl)rVrr�rrr	r�[s
	zIPv6Address.__init__cCs
t|j�S)N)rr()rVrrr	r�szIPv6Address.packedcCs||jjkS)N)r�r�)rVrrr	r��s	zIPv6Address.is_multicastcs#t�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_localcs#t�fdd��jjD��S)Nc3s|]}�|kVqdS)Nr)r�r:)rVrr	r��sz)IPv6Address.is_private.<locals>.<genexpr>)r�r�r�)rVr)rVr	r��s
zIPv6Address.is_privatecCs|jS)N)r�)rVrrr	r��s	zIPv6Address.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	�ipv4_mapped�s	zIPv6Address.ipv4_mappedcCs@|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	�	sixtofour�s	zIPv6Address.sixtofourN)r(r�)rrrrqr�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rUs$

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�rGtj||�t|j�|_|j|_	dSt|t
�r�tj||d�t|�dkr�t|d�|_	n|j|_	t|dd�|_|jj|_|jj
|_
dSt|�}tj||d�t|dd�|_|jj|_|jj	|_	|jj
|_
dS)Nrr%rF)r4r�rjrr�rr(r�r8rHr�r"r�r�r$)rVrr#rrr	r�s(zIPv6Interface.__init__cCs d|j|j�|jjfS)Nz%s/%d)r{r(r�ra)rVrrr	r|#szIPv6Interface.__str__cCsZtj||�}|s%|tkr)|Sy|j|jkSWntk
rUdSYnXdS)NF)rrvrQr�rI)rVrur�rrr	rv's
zIPv6Interface.__eq__cCsktj||�}|tkr"tSy,|j|jkpL|j|jkoL|SWntk
rfdSYnXdS)NF)rrwrQr�rI)rVrur�rrr	rw3s
zIPv6Interface.__lt__cCs|j|jAt|jj�AS)N)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�HszIPv6Interface.with_prefixlencCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r�MszIPv6Interface.with_netmaskcCsd|j|j�|jfS)Nz%s/%s)r{r(r�)rVrrr	r�RszIPv6Interface.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@sCeZdZeZddd�Zdd�Zedd��ZdS)	rTcCstj||�t|ttf�rVt|�|_|j|j�\|_	|_
dSt|t�rt|�dkr�|d}n	|j}|j|�\|_	|_
t|d�|_t|j�}|t|j	�@|kr|r�t
d|��nt|t|j	�@�|_dSt|�}t|j|d��|_t|�dkrc|d}n	|j}|j|�\|_	|_
|r�tt|j�t|j	�@�|jkr�t
d|��tt|j�t|j	�@�|_|j
|jdkr|j|_dS)Nr%rz%s has host bits setr)rNr�r4r�rjrrJr�r8r�rHr�r"r
r$rlr�r�)rVrrr�r�r#rrr	r�ps@ 
	
	zIPv6Network.__init__ccsRt|j�}t|j�}x-t|d|d�D]}|j|�Vq6WdS)Nr%)rjrJrCr�r�)rVr�r�r�rrr	r��szIPv6Network.hostscCs|jjo|jjS)N)rJr�rC)rVrrr	r��szIPv6Network.is_site_localN)	rrrrr�r�r�rrr�rrrr	r`sNrc@s!eZdZed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�g
Zed�ed
�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�gZed�ZdS)�_IPv6Constantsz	fe80::/10zff00::/8z::1/128z::/128z
::ffff:0:0/96z100::/64z	2001::/23z2001:2::/48z
2001:db8::/32z2001:10::/28zfc00::/7z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9z	fec0::/10N)	rrrrr�r�r�r�r�rrrr	r��s*									r�)"�__version__r�r�r�r
rr
rrrrrr$r.r2r;rErMrSrT�total_orderingr5rNrgrrrr�r�r�rrrr�rrrr	�<module>sH#716�:���uSr	��Wz!