AlkantarClanX12

Your IP : 3.144.43.194


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/ipaddress.cpython-39.opt-2.pyc

a

R�f+0�@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#�ZdaejGd$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�Z Gd8d9�d9ee�Z!Gd:d;�d;�Z"e"e_dS)=z1.0�N� �c@seZdZdS)�AddressValueErrorN��__name__�
__module__�__qualname__�r	r	�./opt/alt/python39/lib64/python3.9/ipaddress.pyrsrc@seZdZdS)�NetmaskValueErrorNrr	r	r	r
rsrc	CsVz
t|�WSttfy Yn0z
t|�WSttfyBYn0t|�d���dS)Nz. does not appear to be an IPv4 or IPv6 address)�IPv4Addressrr�IPv6Address�
ValueError��addressr	r	r
�
ip_addresss

rTc	CsZzt||�WSttfy"Yn0zt||�WSttfyFYn0t|�d���dS)Nz. does not appear to be an IPv4 or IPv6 network)�IPv4Networkrr�IPv6Networkr)r�strictr	r	r
�
ip_network8src	CsVz
t|�WSttfy Yn0z
t|�WSttfyBYn0t|�d���dS)Nz0 does not appear to be an IPv4 or IPv6 interface)�
IPv4Interfacerr�
IPv6Interfacerrr	r	r
�ip_interfaceUs

rcCs.z|�dd�WSty(td��Yn0dS)N��bigz&Address negative or too large for IPv4��to_bytes�
OverflowErrorrrr	r	r
�v4_int_to_packedwsrcCs.z|�dd�WSty(td��Yn0dS)N�rz&Address negative or too large for IPv6rrr	r	r
�v6_int_to_packed�s
r cCs,t|��d�}t|�dkr(td|����|S)N�/�zOnly one '/' permitted in )�str�split�lenr)r�addrr	r	r
�_split_optional_netmask�sr'ccsNt|�}t|�}}|D]&}|j|jdkr:||fV|}|}q||fVdS�N�)�iter�next�_ip)�	addresses�it�first�last�ipr	r	r
�_find_address_range�s

r2cCs$|dkr|St|||d@���S)Nrr))�min�
bit_length)Znumber�bitsr	r	r
�_count_righthand_zero_bits�sr6ccs�t|t�rt|t�std��|j|jkr8td||f��||krHtd��|jdkrXt}n|jdkrht}ntd��|j}|j}|j}||kr�t	t
||�||d��d�}||||f�}|V|d|>7}|d|jkr�q�q�dS)Nz1first and last must be IP addresses, not networks�%%s and %s are not of the same versionz*last IP address must be greater than firstr�zunknown IP versionr))
�
isinstance�_BaseAddress�	TypeError�versionrrr�_max_prefixlenr,r3r6r4�	_ALL_ONES)r/r0r1Zip_bitsZ	first_intZlast_intZnbits�netr	r	r
�summarize_address_range�s6
��


�r@ccs�t|�}i}|rV|��}|��}|�|�}|dur<|||<q||kr||=|�|�qd}t|���D]$}|dur�|j|jkr�qf|V|}qfdS�N)�list�pop�supernet�get�append�sorted�values�broadcast_address)r-Zto_merge�subnetsr?rDZexistingr0r	r	r
�_collapse_addresses_internal�s$

rKc	Cs.g}g}g}|D]�}t|t�rR|rF|dj|jkrFtd||df��|�|�q|j|jkr�|r�|dj|jkr�td||df��z|�|j�Wq�ty�|�|j	�Yq�0q|r�|dj|jkr�td||df��|�|�qt
t|��}|�r"t|�D]\}}|�
t||���qt||�S)N���r7)r9r:�_versionr;rF�
_prefixlenr=r1�AttributeError�network_addressrG�setr2�extendr@rK)r-ZaddrsZipsZnetsr1r/r0r	r	r
�collapse_addresses/s:
���rScCs(t|t�r|��St|t�r$|��StSrA)r9�_BaseNetwork�_get_networks_keyr:�_get_address_key�NotImplemented)�objr	r	r
�get_mixed_type_keyes


rYc@s�eZdZdZedd��Zedd��Zedd��Zedd	��Zd
d�Z	dd
�Z
edd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zdd�ZdS)�_IPAddressBaser	cCs|��SrA)�_explode_shorthand_ip_string��selfr	r	r
�exploded�sz_IPAddressBase.explodedcCst|�SrA�r#r\r	r	r
�
compressed�sz_IPAddressBase.compressedcCs|��SrA)�_reverse_pointerr\r	r	r
�reverse_pointer�s	z_IPAddressBase.reverse_pointercCsdt|�f}t|��dS)Nz%200s has no version specified��type�NotImplementedError�r]�msgr	r	r
r<�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)rrMr>r=)r]rrgr	r	r
�_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%rrM)r]rZexpected_lenZaddress_lenrgr	r	r
�_check_packed_address�s�z$_IPAddressBase._check_packed_addresscCs|j|j|?ASrA)r>)�cls�	prefixlenr	r	r
�_ip_int_from_prefix�sz"_IPAddressBase._ip_int_from_prefixc	Cs\t||j�}|j|}||?}d|>d}||krX|jd}|�|d�}d}t||��|S)Nr)�rz&Netmask pattern %r mixes zeroes & ones)r6r=rr)	rj�ip_intZtrailing_zeroesrkZleading_onesZall_onesZbyteslenZdetailsrgr	r	r
�_prefix_from_ip_int�s
�

z"_IPAddressBase._prefix_from_ip_intcCsd|}t|�d�dS)Nz%r is not a valid netmask)r)rjZnetmask_strrgr	r	r
�_report_invalid_netmask�sz&_IPAddressBase._report_invalid_netmaskcCsj|��r|��s|�|�zt|�}WntyB|�|�Yn0d|krZ|jksfn|�|�|S�Nr)�isascii�isdigitrp�intrr=)rjZ
prefixlen_strrkr	r	r
�_prefix_from_prefix_string�s

z)_IPAddressBase._prefix_from_prefix_stringcCs�z|�|�}Wnty*|�|�Yn0z|�|�WStyJYn0||jN}z|�|�WSty~|�|�Yn0dSrA)�_ip_int_from_stringrrprorr>)rj�ip_strrnr	r	r
�_prefix_from_ip_string�s
z%_IPAddressBase._prefix_from_ip_stringcCsHt|ttf�r||jfSt|t�s*t|�}t|�dkr:|S|d|jfS)Nr)r)r9�bytesrtr=�tupler'r%)rjrr	r	r
�_split_addr_prefixs

z!_IPAddressBase._split_addr_prefixcCs|jt|�ffSrA)�	__class__r#r\r	r	r
�
__reduce__,sz_IPAddressBase.__reduce__N)rrr�	__slots__�propertyr^r`rbr<rhri�classmethodrlrorprurxr{r}r	r	r	r
rZ~s0




	




!
rZcspeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Z�ZS)r:r	cCs|jSrA�r,r\r	r	r
�__int__=sz_BaseAddress.__int__cCs6z|j|jko|j|jkWSty0tYS0dSrA)r,rMrOrW�r]�otherr	r	r
�__eq__@s
�z_BaseAddress.__eq__cCsFt|t�stS|j|jkr*td||f��|j|jkrB|j|jkSdS�Nr7F)r9r:rWrMr;r,r�r	r	r
�__lt__Gs
�z_BaseAddress.__lt__cCs t|t�stS|�t|�|�SrA�r9rtrWr|r�r	r	r
�__add__Ss
z_BaseAddress.__add__cCs t|t�stS|�t|�|�SrAr�r�r	r	r
�__sub__Xs
z_BaseAddress.__sub__cCsd|jjt|�fS�Nz%s(%r)�r|rr#r\r	r	r
�__repr__]sz_BaseAddress.__repr__cCst|�|j��SrA)r#�_string_from_ip_intr,r\r	r	r
�__str__`sz_BaseAddress.__str__cCsttt|j���SrA)�hash�hexrtr,r\r	r	r
�__hash__csz_BaseAddress.__hash__cCs
|j|fSrA�rMr\r	r	r
rVfsz_BaseAddress._get_address_keycCs|j|jffSrA)r|r,r\r	r	r
r}isz_BaseAddress.__reduce__cs�|r|ddkrtt|�|�Stdur8ddl}|�d�at�|�}|sRt��|�S|��\}}}|dkr||j	dkrxd}nd}|dkr�|j
}n
|j
d}|r�||dd	7}|r�|d
7}tt|�|�d|�|�|���S)NrL�srz(#?)(_?)([xbnX])�nr�b�xr)r"�0)�formatr#�_address_fmt_re�re�compile�	fullmatch�super�
__format__�groupsrMr=rt)r]Zfmtr��mZ	alternateZgroupingZfmt_baseZpadlen�r|r	r
r�ls*



z_BaseAddress.__format__)rrrr~r�r�r�r�r�r�r�r�rVr}r��
__classcell__r	r	r�r
r:2s	r:c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jdd��Ze
jdd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zed#d$��Zd%d&�Zd'd(�Zd)d*�ZdEd-d.�ZdFd/d0�Zed1d2��Zed3d4��Zd5d6�Z d7d8�Z!ed9d:��Z"ed;d<��Z#ed=d>��Z$ed?d@��Z%edAdB��Z&edCdD��Z'd,S)GrTcCsd|jjt|�fSr�r�r\r	r	r
r��sz_BaseNetwork.__repr__cCsd|j|jfS�N�%s/%d)rPrkr\r	r	r
r��sz_BaseNetwork.__str__ccs8t|j�}t|j�}t|d|�D]}|�|�Vq"dSr(�rtrPrI�range�_address_class�r]�network�	broadcastr�r	r	r
�hosts�s

z_BaseNetwork.hostsccs8t|j�}t|j�}t||d�D]}|�|�Vq"dSr(r�r�r	r	r
�__iter__�s

z_BaseNetwork.__iter__cCslt|j�}t|j�}|dkr>|||kr0td��|�||�S|d7}|||krZtd��|�||�SdS)Nrzaddress out of ranger))rtrPrI�
IndexErrorr�)r]r�r�r�r	r	r
�__getitem__�s

z_BaseNetwork.__getitem__cCs^t|t�stS|j|jkr*td||f��|j|jkrB|j|jkS|j|jkrZ|j|jkSdSr�)r9rTrWrMr;rP�netmaskr�r	r	r
r��s
�z_BaseNetwork.__lt__cCsJz.|j|jko,|j|jko,t|j�t|j�kWStyDtYS0dSrA)rMrPrtr�rOrWr�r	r	r
r��s
��z_BaseNetwork.__eq__cCstt|j�t|j�A�SrA)r�rtrPr�r\r	r	r
r��sz_BaseNetwork.__hash__cCs8|j|jkrdSt|t�rdS|j|jj@|jjkSdS�NF)rMr9rTr,r�rPr�r	r	r
�__contains__�s

z_BaseNetwork.__contains__cCs(|j|vp&|j|vp&|j|vp&|j|vSrA)rPrIr�r	r	r
�overlaps�s



�z_BaseNetwork.overlapscCs|�t|j�t|j�B�SrA)r�rtrP�hostmaskr\r	r	r
rI�s�z_BaseNetwork.broadcast_addresscCs|�t|j�|jA�SrA)r�rtr�r>r\r	r	r
r��sz_BaseNetwork.hostmaskcCsd|j|jfSr�)rPrNr\r	r	r
�with_prefixlen�sz_BaseNetwork.with_prefixlencCsd|j|jfS�N�%s/%s)rPr�r\r	r	r
�with_netmasksz_BaseNetwork.with_netmaskcCsd|j|jfSr�)rPr�r\r	r	r
�
with_hostmasksz_BaseNetwork.with_hostmaskcCst|j�t|j�dSr()rtrIrPr\r	r	r
�
num_addresses
sz_BaseNetwork.num_addressescCsdt|�f}t|��dS)Nz%%200s has no associated address classrcrfr	r	r
r�sz_BaseNetwork._address_classcCs|jSrA)rNr\r	r	r
rksz_BaseNetwork.prefixlenccs|j|jkstd||f��t|t�s2td|��|�|�sLtd||f��||krXdS|�d|j|jf�}|�	�\}}||kr�||kr�|�|�r�|V|�	�\}}qz|�|�r�|V|�	�\}}qzt
d|||f��qz||kr�|Vn"||kr�|Vnt
d|||f��dS)Nr7z%s is not a network objectz%s not contained in %sr�z3Error performing exclusion: s1: %s s2: %s other: %s)rMr;r9rT�	subnet_ofrr|rPrkrJ�AssertionError)r]r��s1�s2r	r	r
�address_excludes>$�


�

��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 typerLr)r)rMr;rPr�r�r	r	r
�compare_networksfs!�z_BaseNetwork.compare_networkscCs|j|j|jfSrA)rMrPr�r\r	r	r
rU�sz_BaseNetwork._get_networks_keyr)Nc	cs�|j|jkr|VdS|durJ||jkr0td��|dkr@td��||j}|dkrZtd��|j|}||jkr~td||f��t|j�}t|j�d}t|j�d|?}t|||�D]}|�||f�}|Vq�dS)Nznew prefix must be longerr)�(cannot set prefixlen_diff and new_prefixrzprefix length diff must be > 0z0prefix length diff %d is invalid for netblock %s)	rNr=rrtrPrIr�r�r|)	r]�prefixlen_diff�
new_prefix�
new_prefixlen�start�end�stepZnew_addrZcurrentr	r	r
rJ�s0



��
z_BaseNetwork.subnetscCs�|jdkr|S|durB||jkr(td��|dkr8td��|j|}|j|}|dkrftd|j|f��|�t|j�t|j�|>@|f�S)Nrznew prefix must be shorterr)r�z;current prefixlen is %d, cannot have a prefixlen_diff of %d)rNrrkr|rtrPr�)r]r�r�r�r	r	r
rD�s&



���z_BaseNetwork.supernetcCs|jjo|jjSrA)rP�is_multicastrIr\r	r	r
r��s	�z_BaseNetwork.is_multicastcCsfz:|j|jkr"t|�d|�d���|j|jko8|j|jkWSty`td|�d|����Yn0dS)Nz and z are not of the same versionz*Unable to test subnet containment between )rMr;rPrIrO)�ar�r	r	r
�
_is_subnet_of
s
���z_BaseNetwork._is_subnet_ofcCs|�||�SrA�r�r�r	r	r
r�sz_BaseNetwork.subnet_ofcCs|�||�SrAr�r�r	r	r
�supernet_ofsz_BaseNetwork.supernet_ofcCs|jjo|jjSrA)rP�is_reservedrIr\r	r	r
r�s	�z_BaseNetwork.is_reservedcCs|jjo|jjSrA)rP�
is_link_localrIr\r	r	r
r�*s�z_BaseNetwork.is_link_localcCs|jjo|jjSrA)rP�
is_privaterIr\r	r	r
r�5s	�z_BaseNetwork.is_privatecCs|jSrA�r�r\r	r	r
�	is_globalAs	z_BaseNetwork.is_globalcCs|jjo|jjSrA)rP�is_unspecifiedrIr\r	r	r
r�Ls	�z_BaseNetwork.is_unspecifiedcCs|jjo|jjSrA)rP�is_loopbackrIr\r	r	r
r�Xs	�z_BaseNetwork.is_loopback)r)N)r)N)(rrrr�r�r�r�r�r�r�r�r�r��	functools�cached_propertyrIr�rr�r�r�r�r�rkr�r�rUrJrDr��staticmethodr�r�r�r�r�r�r�r�r�r	r	r	r
rT�sb








K0

5
)








rTc@s�eZdZdZdZdedZeZiZdd�Z	e
dd��Ze
d	d
��Ze
dd��Z
e
d
d��Zdd�Zedd��Zedd��ZdS)�_BaseV4r	rr"r)cCst|�SrAr_r\r	r	r
r[wsz$_BaseV4._explode_shorthand_ip_stringcCs�||jvr�t|t�r<|}d|kr.|jkshn|�|�n,z|�|�}Wntyf|�|�}Yn0t|�	|��}||f|j|<|j|Srq)
�_netmask_cacher9rtr=rprurrxrrl�rj�argrkr�r	r	r
�
_make_netmaskzs	

z_BaseV4._make_netmaskc
Cs�|std��|�d�}t|�dkr.td|��zt�t|j|�d�WStyz}ztd||f�d�WYd}~n
d}~00dS)N�Address cannot be empty�.rzExpected 4 octets in %rr�%s in %r)rr$r%rt�
from_bytes�map�_parse_octetr)rjrwZoctets�excr	r	r
rv�s
z_BaseV4._ip_int_from_stringcCs�|std��|��r|��s,d}t||��t|�dkrHd}t||��|dkrl|ddkrld}t||��t|d�}|d	kr�td
|��|S)NzEmpty octet not permittedz#Only decimal digits permitted in %r�z$At most 3 characters permitted in %rr�rz%Leading zeros are not permitted in %r�
�zOctet %d (> 255) not permitted)rrrrsr%rt)rjZ	octet_strrgZ	octet_intr	r	r
r��s
z_BaseV4._parse_octetcCsd�tt|�dd���S)Nr�rr)�joinr�r#r)rjrnr	r	r
r��sz_BaseV4._string_from_ip_intcCs&t|��d�ddd�}d�|�dS)Nr�rLz
.in-addr.arpa)r#r$r�)r]Zreverse_octetsr	r	r
ra�sz_BaseV4._reverse_pointercCs|jSrA�r=r\r	r	r
�
max_prefixlen�sz_BaseV4.max_prefixlencCs|jSrAr�r\r	r	r
r<�sz_BaseV4.versionN)rrrr~rM�
IPV4LENGTHr>r=r�r[r�r�rvr�r�rarr�r<r	r	r	r
r�ds&	


#
	
r�c@s�eZdZdZdd�Zedd��Zedd��Zee�	�dd	���Z
ee�	�d
d���Zedd
��Zedd��Z
edd��Zedd��ZdS)r)r,�__weakref__cCstt|t�r|�|�||_dSt|t�rF|�|d�t�|d�|_dSt|�}d|vrdtd|����|�	|�|_dS)Nrrr!�Unexpected '/' in )
r9rtrhr,ryrir�r#rrv�r]rZaddr_strr	r	r
�__init__�s


zIPv4Address.__init__cCs
t|j�SrA)rr,r\r	r	r
�packedszIPv4Address.packedcCs||jjvSrA)�
_constants�_reserved_networkr\r	r	r
r�s	zIPv4Address.is_reservedcs4t�fdd��jjD��o2t�fdd��jjD��S)Nc3s|]}�|vVqdSrAr	��.0r?r\r	r
�	<genexpr><�z)IPv4Address.is_private.<locals>.<genexpr>c3s|]}�|vVqdSrAr	r�r\r	r
r�=r�)�anyr��_private_networks�all�_private_networks_exceptionsr\r	r\r
r�*s�zIPv4Address.is_privatecCs||jjvo|jSrA)r��_public_networkr�r\r	r	r
r�@szIPv4Address.is_globalcCs||jjvSrA�r��_multicast_networkr\r	r	r
r�Rs	zIPv4Address.is_multicastcCs||jjkSrA)r��_unspecified_addressr\r	r	r
r�]s	zIPv4Address.is_unspecifiedcCs||jjvSrA)r��_loopback_networkr\r	r	r
r�hszIPv4Address.is_loopbackcCs||jjvSrA�r��_linklocal_networkr\r	r	r
r�rszIPv4Address.is_link_localN)rrrr~r�rr�r�r��	lru_cacher�r�r�r�r�r�r	r	r	r
r�s(#







	rc@sxeZdZdd�Zejdd��Zdd�Zdd�Zd	d
�Z	dd�Z
ejZe
d
d��Ze
dd��Ze
dd��Ze
dd��ZdS)rcCsD|�|�\}}t�||�t||fdd�|_|jj|_|jj|_dS�NF)r)r{rr�rr�r�rN�r]rr&�maskr	r	r
r�s

zIPv4Interface.__init__cCs|jjSrA�r�r�r\r	r	r
r��szIPv4Interface.hostmaskcCsd|�|j�|jfSr��r�r,rNr\r	r	r
r��s�zIPv4Interface.__str__cCsDt�||�}|tus|s|Sz|j|jkWSty>YdS0dSr�)rr�rWr�rO�r]r�Z
address_equalr	r	r
r��szIPv4Interface.__eq__cCsPt�||�}|turtSz|j|jkp4|j|jko4|WStyJYdS0dSr�)rr�rWr�rO�r]r�Zaddress_lessr	r	r
r��s�zIPv4Interface.__lt__cCst|j|jt|jj�f�SrA�r�r,rNrtr�rPr\r	r	r
r��szIPv4Interface.__hash__cCs
t|j�SrA)rr,r\r	r	r
r1�szIPv4Interface.ipcCsd|�|j�|jfSr�rr\r	r	r
r��s�zIPv4Interface.with_prefixlencCsd|�|j�|jfSr��r�r,r�r\r	r	r
r��s�zIPv4Interface.with_netmaskcCsd|�|j�|jfSr��r�r,r�r\r	r	r
r��s�zIPv4Interface.with_hostmaskN)rrrr�r�r�r�r�r�r�r�rZr}rr1r�r�r�r	r	r	r
r}s 



rc@s.eZdZeZddd�Zee��dd���Z	dS)rTcs�|�|�\�}t��|_|�|�\|_|_t|j�}|t|j�@|krl|rXtd|��nt|t|j�@�|_|j|jdkr�|j	|_
n|j|jkr��fdd�|_
dS)N�%s has host bits setr)cs
t��gSrA)rr	�r&r	r
�<lambda>r�z&IPv4Network.__init__.<locals>.<lambda>)r{rrPr�r�rNrtrr=r�r��r]rrrr�r	rr
r��s#

�
zIPv4Network.__init__cCs&|jtd�vo|jtd�vo$|jS)N�
100.64.0.0/10)rPrrIr�r\r	r	r
r�s

��zIPv4Network.is_globalN)T)
rrrrr�r�rr�rr�r	r	r	r
r�s


4rc@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/4rz	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�rr�r	r	r	r
rs0��rc@s�eZdZdZdZdedZdZed�Z	eZ
iZedd��Z
ed	d
��Zedd��Zed
d��Zeddd��Zdd�Zdd�Zedd��Zedd��Zedd��ZdS)�_BaseV6r	r8r"r)rmZ0123456789ABCDEFabcdefcCsl||jvrbt|t�r<|}d|kr.|jksFn|�|�n
|�|�}t|�|��}||f|j|<|j|Srq)r�r9rtr=rprur
rlr�r	r	r
r�Os	


z_BaseV6._make_netmaskc
Cs�|std��|�d�}d}t|�|kr:d||f}t|��d|dvr�zt|���j}Wn6ty�}ztd||f�d�WYd}~n
d}~00|�d|d	?d
@�|�d|d
@�|jd}t|�|kr�d|d|f}t|��d}tdt|�d�D]*}	||	s�|du�r"d
|}t|��|	}q�|du�r�|}
t|�|d}|d�sn|
d8}
|
�rnd}t||��|d�s�|d8}|�r�d}t||��|j|
|}|dk�r4d}t||jd|f��njt|�|jk�r�d}t||j|f��|d�s
d}t||��|d�s$d}t||��t|�}
d}d}znd}
t|
�D] }	|
d	K}
|
|�	||	�O}
�qB|
d	|K}
t|d�D] }	|
d	K}
|
|�	||	�O}
�q||
WSt
�y�}ztd||f�d�WYd}~n
d}~00dS)Nr��:r�z At least %d parts expected in %rr�rLr��%xr�r)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 %r)rr$r%rrCr,rF�
_HEXTET_COUNTr��
_parse_hextetr)rjrw�partsZ
_min_partsrgZipv4_intr�Z
_max_partsZ
skip_index�iZparts_hiZparts_loZ
parts_skippedrnr	r	r
rvcs�
(







z_BaseV6._ip_int_from_stringcCs>|j�|�std|��t|�dkr4d}t||��t|d�S)NzOnly hex digits permitted in %rrz$At most 4 characters permitted in %rr)�_HEX_DIGITS�
issupersetrr%rt)rjZ
hextet_strrgr	r	r
r�sz_BaseV6._parse_hextetc	Cs�d}d}d}d}t|�D]>\}}|dkrN|d7}|dkr<|}||krV|}|}qd}d}q|dkr�||}|t|�kr~|dg7}dg|||�<|dkr�dg|}|S)NrLrr�r)�)�	enumerater%)	rj�hextetsZbest_doublecolon_startZbest_doublecolon_lenZdoublecolon_startZdoublecolon_len�indexZhextetZbest_doublecolon_endr	r	r
�_compress_hextets�s0�

z_BaseV6._compress_hextetsNcsZ|durt|j�}||jkr$td��d|��fdd�tddd�D�}|�|�}d�|�S)	NzIPv6 address is too large�%032xcs&g|]}dt�||d�d��qS)rrr)rt�r�r��Zhex_strr	r
�
<listcomp>*r�z/_BaseV6._string_from_ip_int.<locals>.<listcomp>rrrr)rtr,r>rr�rr�)rjrnrr	r"r
r�s


z_BaseV6._string_from_ip_intcs�t|t�rt|j�}nt|t�r,t|j�}nt|�}|�|�}d|��fdd�tddd�D�}t|ttf�r�dd�	|�|j
fSd�	|�S)	Nr csg|]}�||d��qS)rr	r!r"r	r
r#Br�z8_BaseV6._explode_shorthand_ip_string.<locals>.<listcomp>rrrr�r)r9rr#rPrr1rvr�rTr�rN)r]rwrnrr	r"r
r[/s



z$_BaseV6._explode_shorthand_ip_stringcCs&|jddd��dd�}d�|�dS)NrLrrr�z	.ip6.arpa)r^�replacer�)r]Z
reverse_charsr	r	r
raGsz_BaseV6._reverse_pointercCs:|�d�\}}}|sd}n|r&d|vr2td|��||fS)N�%zInvalid IPv6 address: "%r")�	partitionr)rwr&�sep�scope_idr	r	r
�_split_scope_idPs
z_BaseV6._split_scope_idcCs|jSrAr�r\r	r	r
r�dsz_BaseV6.max_prefixlencCs|jSrAr�r\r	r	r
r<hsz_BaseV6.version)N)rrrr~rM�
IPV6LENGTHr>r�	frozensetrr=r�r�r�rvrrr�r[rar�r)rr�r<r	r	r	r
r;s2	

g

/	

rcs�eZdZdZdd�Z�fdd�Zdd�Z�fdd	�Zed
d��Z	edd
��Z
edd��Zedd��Zedd��Z
edd��Zee��dd���Zedd��Zedd��Zedd��Zedd��Zed d!��Zed"d#��Z�ZS)$r
)r,�	_scope_idr�cCs�t|t�r$|�|�||_d|_dSt|t�rR|�|d�t�|d�|_d|_dSt|�}d|vrpt	d|����|�
|�\}|_|�|�|_dS)Nrrr!r�)r9rtrhr,r,ryrir�r#rr)rvr�r	r	r
r�ss


zIPv6Address.__init__cs"t���}|jr|d|jS|S)Nr%)r�r�r,)r]rwr�r	r
r��s
zIPv6Address.__str__cCst|j|jf�SrA)r�r,r,r\r	r	r
r��szIPv6Address.__hash__cs2t��|�}|turtS|s dS|jt|dd�kS)NFr,)r�r�rWr,�getattrrr�r	r
r��szIPv6Address.__eq__cCs|jSrA)r,r\r	r	r
r(�s
zIPv6Address.scope_idcCs
t|j�SrA)r r,r\r	r	r
r��szIPv6Address.packedcCs||jjvSrAr�r\r	r	r
r��s	zIPv6Address.is_multicastcst�fdd��jjD��S)Nc3s|]}�|vVqdSrAr	r!r\r	r
r��r�z*IPv6Address.is_reserved.<locals>.<genexpr>)r�r��_reserved_networksr\r	r\r
r��s	zIPv6Address.is_reservedcCs||jjvSrAr�r\r	r	r
r��szIPv6Address.is_link_localcCs||jjvSrA)r��_sitelocal_networkr\r	r	r
�
is_site_local�szIPv6Address.is_site_localcsH�j}|dur|jSt�fdd��jjD��oFt�fdd��jjD��S)Nc3s|]}�|vVqdSrAr	r�r\r	r
r��r�z)IPv6Address.is_private.<locals>.<genexpr>c3s|]}�|vVqdSrAr	r�r\r	r
r��r�)�ipv4_mappedr�r�r�r�r�r�)r]r1r	r\r
r��s�zIPv6Address.is_privatecCs|jSrAr�r\r	r	r
r�szIPv6Address.is_globalcCs
|jdkSrqr�r\r	r	r
r�s	zIPv6Address.is_unspecifiedcCs
|jdkSr(r�r\r	r	r
r�s	zIPv6Address.is_loopbackcCs |jd?dkrdSt|jd@�S)Nrr����r,rr\r	r	r
r1)s	zIPv6Address.ipv4_mappedcCs4|jd?dkrdSt|jd?d@�t|jd@�fS)N�`i �@r2r3r\r	r	r
�teredo6s

�zIPv6Address.teredocCs$|jd?dkrdSt|jd?d@�S)N�pi �Pr2r3r\r	r	r
�	sixtofourEs	zIPv6Address.sixtofour)rrrr~r�r�r�r�rr(r�r�r�r�r0r�rr�r�r�r�r1r6r9r�r	r	r�r
r
ms@(






	








r
cs�eZdZdd�Zejdd��Z�fdd�Zdd�Zd	d
�Z	dd�Z
ejZe
d
d��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Z�ZS)rcCsD|�|�\}}t�||�t||fdd�|_|jj|_|jj|_dSr)r{r
r�rr�r�rNrr	r	r
r�Us

zIPv6Interface.__init__cCs|jjSrArr\r	r	r
r�]szIPv6Interface.hostmaskcsdt���|jfSr�)r�r�rNr\r�r	r
r�as
�zIPv6Interface.__str__cCsDt�||�}|tus|s|Sz|j|jkWSty>YdS0dSr�)r
r�rWr�rOrr	r	r
r�eszIPv6Interface.__eq__cCsPt�||�}|tur|Sz|j|jkp4|j|jko4|WStyJYdS0dSr�)r
r�rWr�rOrr	r	r
r�qs�zIPv6Interface.__lt__cCst|j|jt|jj�f�SrArr\r	r	r
r�}szIPv6Interface.__hash__cCs
t|j�SrA)r
r,r\r	r	r
r1�szIPv6Interface.ipcCsd|�|j�|jfSr�rr\r	r	r
r��s�zIPv6Interface.with_prefixlencCsd|�|j�|jfSr�r	r\r	r	r
r��s�zIPv6Interface.with_netmaskcCsd|�|j�|jfSr�r
r\r	r	r
r��s�zIPv6Interface.with_hostmaskcCs|jdko|jjSrq)r,r�r�r\r	r	r
r��szIPv6Interface.is_unspecifiedcCs|jdko|jjSr()r,r�r�r\r	r	r
r��szIPv6Interface.is_loopback)rrrr�r�r�r�r�r�r�r�rZr}rr1r�r�r�r�r�r�r	r	r�r
rSs(





rc@s.eZdZeZd	dd�Zdd�Zedd��ZdS)
rTcs�|�|�\�}t��|_|�|�\|_|_t|j�}|t|j�@|krl|rXtd|��nt|t|j�@�|_|j|jdkr�|j	|_
n|j|jkr��fdd�|_
dS)Nrr)cs
t��gSrA)r
r	rr	r
r
�r�z&IPv6Network.__init__.<locals>.<lambda>)r{r
rPr�r�rNrtrr=r�r�rr	rr
r��s

�
zIPv6Network.__init__ccs<t|j�}t|j�}t|d|d�D]}|�|�Vq&dSr(r�r�r	r	r
r��s

zIPv6Network.hostscCs|jjo|jjSrA)rPr0rIr\r	r	r
r0�s�zIPv6Network.is_site_localN)T)	rrrr
r�r�r�rr0r	r	r	r
r�s

0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/r	r	r	r
r:�s<��
�r:)T)#�__version__r�r�r*rrrrrrrr r'r2r6r@rKrSrYrZr��total_orderingr:rTr�rrrrr�rr
rrr:r	r	r	r
�<module>sX
"7163kH
CR&4gK\-