Ñò ô†³Kc @s-dZdZdZdZdZddkZddkZdeifd„ƒYZe d „Z e d „Z e d joµed ƒZ ed ddƒZe GHxe iƒD] ZeGHq¤WxeiƒD] ZeGHqÀWxe eBiƒD] ZeGHqàWxe eAiƒD] ZeGHqWxe 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 s0.2t3s 2006-01-20iÿÿÿÿNtIP4RangecBs¶eZdZdZdZdigZedƒD]Zee eƒq/[ƒZ dZ d„Z d„Z d „Zd „Zd „Zd „Zd „Zd„Zd„ZeZd„ZRS(sbIP4 address range class with efficient storage of address ranges. Supports all set operations.iii tis 0123456789.cGsBt|ƒdjo3t|dtƒott|ƒi|dƒdSt|ƒ}xÁtt|ƒƒD]­}||}t|tƒozd|jo&|i|i ddƒŒ||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((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyR&s<'    # cCsÆt|ƒ\}}t|ƒ\}}||jo0||d||d>d|d>@7}|}n||jotdƒ‚n|d|dK}|d|dK}|dd|d>d7}||fS(Niis!Range has more dots than address.i(t _parseAddrR(RRRtnaddr1t naddr1lentnaddr2t naddr2len((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyR js    c Cstt|ƒ\}}|d|dK}yI|p d}n t|ƒ}d|jo djnp t‚nWnÊtj o¾yt|tƒ}Wntj otdƒ‚nXd}d}|p d}q:x|d@p|d7}qÓWx$|d@o|dL}|d7}qðW||djotdƒ‚q:nX|d|>dd|>@}|dd|>d}||fS(Niiii sMask isn't parseable.isMask isn't a proper host mask.(RRRtFalse( Rtaddrtmasktnaddrtnaddrlentmasklent remainingRR ((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyRxs:      cCsTt|ƒ\}}|d|d>}|d|d>dd|d>d}||fS(Niii(R(RR#R%R&RR ((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyR—s&cCsQg}x5tdƒD]'}|it|d@ƒƒ|dL}qWdit|ƒƒS(Niiÿis.(R tappendR tjointreversed(RtnumtrvR((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyt_int2ip¡s  ccs2x+tt|ƒiƒD]}|i|ƒ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((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyt iteraddresses«sccstxm|iD]b}|d|ddjo|i|dƒVq d|i|dƒ|i|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((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyt iterranges²s  ccs7x0|iD]%}x|i|ƒ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((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyt itermasks½s  ccs|g}x|o|iƒ}d}xutomdd|>}|d|dd|>dd|>@}||djo|||djoPq(|d7}q(Wd|i|ƒ|fV|d|jo|i|d|fƒn|d||jo|i|||dfƒq q WdS(Niii s%s/%s(tpoptTrueR.R)(RR3trangestcurtcurmaskt curmasklentstart((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyR5Æs"  &&cCsœg}xv|iD]k\}}||djo!|id|i|ƒfƒq|id|i|ƒ|i|dƒfƒqWd|iidi|ƒ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((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyt__repr__Ýs !llÿÿ(R?t __module__t__doc__RRR*t_[1]R tntchrt _UNITYTRANSt _IPREMOVERR RRR.R1R4R6R5R/RA(((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyRs 6 D    c Cs2|oU|ititiƒo<yti|ƒ}Wq\tij otdƒ‚q\Xnd}x¿t|i dƒƒD]¨\}}|djotdƒ‚nyI|p d}n t |ƒ}d|jo djnp t‚nWntj otdƒ‚nX|dK}||7}qxW||d fS( NsInvalid Hostname as argument.is.is&Address contains more than four parts.isAddress part out of range.ii( t translateRRGRHtsockett gethostbynameterrorRt enumerateR R(R#tlookupR%tnaddrpostpart((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyRés*      cCst|d|ƒdS(NRNi(R(R#RN((s2/usr/lib/python2.6/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__tintsetRJtIntSetRR8RRQR?txtyR6tvalR4(((s2/usr/lib/python2.6/site-packages/paste/util/ip4.pyts8  Ì