%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/util/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyo

�
b�Nc@s+dZdZdZdZdZddlZddlZdejfd��YZe	d	�Z
e	d
�Zedkr'ed�Z
ed
dd�Ze
GHxe
j�D]ZeGHq�Wxej�D]ZeGHq�Wxe
eBj�D]ZeGHq�Wxe
eAj�D]ZeGHq�Wxe
D]ZeGHqWndS(s�IP4 address range set implementation.

Implements an IPv4-range type.

Copyright (C) 2006, Heiko Wundram.
Released under the MIT-license.
s Heiko Wundram <me@modelnine.org>s0.2t3s
2006-01-20i����NtIP4RangecBs�eZdZdZdZdjged�D]Zee�^q+�Z	dZ
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�ZeZd�ZRS(sbIP4 address range class with efficient storage of address ranges.
    Supports all set operations.iii tis0123456789.cGs+t|�dkrCt|dt�rCtt|�j|d�dSt|�}x�tt|��D]�}||}t|t�r�d|kr�|j|j	dd��||<qbq�d|kr�|j
|j	dd��||<q�|j|�||<qbt|t�r�tt�dkr&t
d��n|\}}t|t�rW|j|�d}n$t|ttf�s{td��nt|t�r�|j|�d}n$t|ttf�s�td��n||f||<qbt|ttf�sbtd��qbqbWtt|�jd	|jd
|j|�dS(sHInitialize an ip4range class. The constructor accepts an unlimited
        number of arguments that may either be tuples in the form (start,stop),
        integers, longs or strings, where start and stop in a tuple may
        also be of the form integer, long or string.

        Passing an integer or long means passing an IPv4-address that's already
        been converted to integer notation, whereas passing a string specifies
        an address where this conversion still has to be done. A string
        address may be in the following formats:

        - 1.2.3.4    - a plain address, interpreted as a single address
        - 1.2.3      - a set of addresses, interpreted as 1.2.3.0-1.2.3.255
        - localhost  - hostname to look up, interpreted as single address
        - 1.2.3<->5  - a set of addresses, interpreted as 1.2.3.0-1.2.5.255
        - 1.2.0.0/16 - a set of addresses, interpreted as 1.2.0.0-1.2.255.255

        Only the first three notations are valid if you use a string address in
        a tuple, whereby notation 2 is interpreted as 1.2.3.0 if specified as
        lower bound and 1.2.3.255 if specified as upper bound, not as a range
        of addresses.

        Specifying a range is done with the <-> operator. This is necessary
        because '-' might be present in a hostname. '<->' shouldn't be, ever.
        iiNs<->s/isTuple is of invalid length.sInvalid argument.tmintmax(tlent
isinstanceRtsupert__init__tlisttrangetstrt_parseRangetsplitt
_parseMaskt_parseAddrRangettuplet
ValueErrortinttlongt	TypeErrort_MINIP4t_MAXIP4(tselftargstitargvaltaddr1taddr2((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyR&s:%
"cCs�t|�\}}t|�\}}||kr_||d||d>d|d>@7}|}n||krztd��n|d|dK}|d|dK}|dd|d>d7}||fS(Niis!Range has more dots than address.i(t
_parseAddrR(RRRtnaddr1t	naddr1lentnaddr2t	naddr2len((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyRjs
	c	Csct|�\}}|d|dK}yD|s6d}nt|�}d|koYdknsgt�nWn�tk
r(yt|t�}Wntk
r�td��nXd}d}|s�d}q)x|d@s�|d7}q�Wx"|d@r|dL}|d7}q�W||dkr)td��q)nX|d|>dd|>@}|dd|>d}||fS(Niiii sMask isn't parseable.isMask isn't a proper host mask.(RRRtFalse(	Rtaddrtmasktnaddrtnaddrlentmasklent	remainingRR ((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyRxs6	


	


cCsTt|�\}}|d|d>}|d|d>dd|d>d}||fS(Niii(R(RR#R%R&RR ((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyR�s&cCsQg}x5td�D]'}|jt|d@��|dL}qWdjt|��S(Nii�is.(R
tappendRtjointreversed(RtnumtrvR((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyt_int2ip�s
ccs2x+tt|�j�D]}|j|�VqWdS(swReturns an iterator which iterates over ips in this iprange. An
        IP is returned in string form (e.g. '1.2.3.4').N(RRt__iter__R.(Rtv((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyt
iteraddresses�sccsrxk|jD]`}|d|ddkr=|j|d�Vq
d|j|d�|j|dd�fVq
WdS(s�Returns an iterator which iterates over ip-ip ranges which build
        this iprange if combined. An ip-ip pair is returned in string form
        (e.g. '1.2.3.4-2.3.4.5').iis%s-%sN(t_rangesR.(Rtr((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyt
iterranges�sccs7x0|jD]%}x|j|�D]}|Vq Wq
WdS(s�Returns an iterator which iterates over ip/mask pairs which build
        this iprange if combined. An IP/Mask pair is returned in string form
        (e.g. '1.2.3.0/24').N(R2t
_itermasks(RR3R0((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyt	itermasks�sccs|g}x|r|j�}d}xptr�dd|>}|d|dd|>dd|>@}||dkr�|||dkr�Pq'|d7}q'Wd|j|�|fV|d|kr�|j|d|f�n|d||kr|j|||df�qqWdS(Niii s%s/%s(tpoptTrueR.R)(RR3trangestcurtcurmaskt
curmasklentstart((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyR5�s			&$cCs�g}xt|jD]i\}}||dkrL|jd|j|�f�q|jd|j|�|j|d�f�qWd|jjdj|�fS(s?Returns a string which can be used to reconstruct this iprange.is%rs(%r,%r)s%s(%s)s,(R2R)R.t	__class__t__name__R*(RR-R=tstop((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyt__repr__�s II����(R?t
__module__t__doc__RRR*R
tntchrt_UNITYTRANSt	_IPREMOVERRRRR.R1R4R6R5R/RA(((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyRs .	D			
	
					cCs$|rW|jtjtj�rWytj|�}WqWtjk
rStd��qWXnd}x�t|j	d��D]�\}}|dkr�td��nyD|s�d}nt
|�}d|ko�dkns�t�nWntk
r�td��nX|dK}||7}qsW||d	fS(
NsInvalid Hostname as argument.is.is&Address contains more than four parts.isAddress part out of range.ii(t	translateRRFRGtsockett
gethostbynameterrorRt	enumerateR
R(R#tlookupR%tnaddrpostpart((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyR�s("	


cCst|d|�dS(NRMi(R(R#RM((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pytip2intst__main__s172.22.162.250/24s172.22.162.250s172.22.163.250s172.22.163.253<->255(RCt
__author__t__version__t__revision__t__date__tintsetRItIntSetRR8RRPR?txtyR6tvalR4(((s?/opt/alt/python27/lib/python2.7/site-packages/paste/util/ip4.pyt<module>s.�				


Zerion Mini Shell 1.0