Ñò î¡ßNc@s¬dZdZdZdZdZddkZeiddjo eZ ne Z dd k l Z l Z d efd „ƒYZeeƒZeeƒZd efd „ƒYZdS(sÑImmutable integer set type. Integer set class. Copyright (C) 2010, David Moss. Ported to Python 3.x. Copyright (C) 2006, Heiko Wundram. Released under the MIT license: Copyright (c) 2006, Heiko Wundram. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. s Heiko Wundram s0.2t7s 2006-01-23iÿÿÿÿNii(t _func_namet _func_doct _InfinitycBs_eZdZdgZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( s0Internal type used to represent infinity values.t_negcCs ||_dS(N(R(tselftneg((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__init__BscCs@t|tttfƒptS|iot|tƒo|i S(N(t isinstancetintt_longRtNotImplementedR(Rtvalue((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__lt__Es cCs%t|tttfƒptS|iS(N(RR R RR R(RR ((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__le__KscCsAt|tttfƒptS|ipt|tƒo|i S(N(RR R RR R(RR ((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__gt__Ps cCs&t|tttfƒptS|i S(N(RR R RR R(RR ((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__ge__VscCs>t|tttfƒptSt|tƒo|i|ijS(N(RR R RR R(RR ((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__eq__[scCs?t|tttfƒptSt|tƒ p|i|ijS(N(RR R RR R(RR ((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__ne__`scCsdS(NtNone((R((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__repr__es( t__name__t __module__t__doc__t __slots__RR RRRRRR(((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyR=s        tIntSetcBsœeZdZddddgZd„Zeed„Zd„Zd„Z dJd „Z e d d d d „ƒZ e dd d d„ƒZ e dd d d„ƒZe dd dd„ƒZe dd dd„ƒZe dd dd„ƒZe dd dd„ƒZe dd dd„ƒZe dd dd„ƒZe d d d!d"„ƒZe d#d d!d$„ƒZe d%d d!d&„ƒZe d'd(d)d*„ƒZe d+d(d,d-„ƒZe d.d(d/d0„d1„ƒZe d2d(d)d3„ƒZe d4d(d5d6„d7„ƒZe d8d(d9d:„d;„ƒZe d<d(d=d>„ƒZe d?d(d@dA„dB„ƒZ[ dC„Z e Z!dD„Z"dE„Z#dF„Z$dG„Z%e%Z&dH„Z'dI„Z(RS(KsvInteger set class with efficient storage in a RLE format of ranges. Supports minus and plus infinity in the range.t_rangest_mint_maxt_hashcOsët|ƒdjopt|dtƒo\|otdƒ‚n|di|_|di|_|di|_|di|_dSg|_|idt ƒ|_|idt ƒ|_|idjo t |_n|idjo t |_n|otdƒ‚nt|it t fƒp |it jptdƒ‚nt|it t fƒp |it jptd ƒ‚n|it j o3|it j o#|i|ijotd ƒ‚nt|it t fƒo|id7_nxò|D]ê}t|t t fƒo||d}}n<t|tƒot|ƒd jotd ƒ‚n|\}}|djo |i}n|djo |i}nt|t t fƒp |t jptd ƒ‚nt|t t fƒp |t jptdƒ‚n|t j o!|t j o||joqïnt|t t fƒo|d7}q[n tdƒ‚||ijoqïn||ijo |i}n||ijoqïn||ijo |i}n|ii||fƒqïW|iƒdS(sInitialize an integer set. The constructor accepts an unlimited number of arguments that may either be tuples in the form of (start, stop) where either start or stop may be a number or None to represent maximum/minimum in that direction. The range specified by (start, stop) is always inclusive (differing from the builtin range operator). Keyword arguments that can be passed to an integer set are min and max, which specify the minimum and maximum number in the set, respectively. You can also pass None here to represent minus or plus infinity, which is also the default. iis*No keyword arguments for copy constructor.NtmintmaxsInvalid keyword argument.sInvalid type of min argument.sInvalid type of max argument.s$Minimum is not smaller than maximum.is$Invalid tuple, must be (start,stop).sInvalid type of tuple start.sInvalid type of tuple stop.sInvalid argument.(tlenRRt ValueErrorRRRRtpopt_MININFt_MAXINFRR R t TypeErrorttupletappendt _normalize(Rtargstkwargstargtstarttstop((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRsst'   ))      ##    ccs‘|}htd6td6}dt|ƒdt|ƒ}}d\} } x!| |jp | |jo| |jo~| |jo-|| d?| d@|| d?| d@jp | |jo7|| d?| d@d| d@ } } } | d7} n4|| d?| d@d| d@ } } } | d7} || jo-| |joPn||| ffV| }n| || R(RRAtcoercedtnewsettstatesR,R-(tpall(s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pytfs&    ""tboolc sº|i|ƒ}|tjotS|d}t|i|iƒ}t|i|iƒ}ˆ }xW|i|i|i||ƒD]7\}\}}ˆ|ƒptS|p ˆ|ƒ}q{W|S(Ni( RBR RRRRR<RR0( RRARERRtfoundRGR,R-(RHtpany(s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRI.s    s#Invalid type of function to create.(R!RR(tnamettypetdocRHRLRI((RLRHs5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt_make_function s     t__and__RCs&Intersection of two sets as a new set.cCs|do|dS(R.R/((ts((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pytFst__rand__cCs|do|dS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSIst intersectioncCs|do|dS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSLst__or__sUnion of two sets as a new set.cCs|dp|dS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSQst__ror__cCs|dp|dS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSTstunioncCs|dp|dS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSWst__sub__s$Difference of two sets as a new set.cCs|do |d S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRS\st__rsub__cCs|do |d S(R/R.((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRS_st differencecCs|do |d S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSbst__xor__s.Symmetric difference of two sets as a new set.cCs|d|dAS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSgst__rxor__cCs|d|dAS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSjstsymmetric_differencecCs|d|dAS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSmst __contains__RJs*Returns true if self is superset of other.cCs|dp |d S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSrstissubsets(Returns true if self is subset of other.cCs|dp |d S(R/R.((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSust istruesubsets-Returns true if self is true subset of other.cCs|dp |d S(R/R.((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSxscCs|do |d S(R/R.((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSyst issupersetcCs|dp |d S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRS|stistruesupersets/Returns true if self is true superset of other.cCs|dp |d S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSscCs|do |d S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRS€stoverlapss)Returns true if self overlaps with other.cCstS((tTrue(RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSƒscCs|do|dS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRS„sRs'Returns true if self is equal to other.cCs|d|dA S(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRS‰sRs+Returns true if self is different to other.cCstS((Re(RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSŒscCs|d|dAS(R.R/((RR((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyRSscCs½|ii|iƒ}|i|_|i|_g|_|i}xJ|iD]?}||djo(|ii||dfƒ|d}qIqIW||ijo|ii||ifƒn|S(sInverse of set as a new set.ii(R?RDRRRR'(RRFtlaststoptr((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pytinverse“s     cCs|iS(s¦Returns a hash value representing this integer set. As the set is always stored normalized, the hash value is guaranteed to match for matching ranges.(R(R((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__hash__¨scCs |ipdS|iddtjp|iddtjotdƒ‚nd}x'|iD]}||d|d7}q_W|djotdƒ‚n|S( såGet length of this integer set. In case the length is larger than 2**31 (including infinitely sized integer sets), it raises an OverflowError. This is due to len() restricting the size to 0 <= len < 2**31.iiÿÿÿÿisInfinitely sized integer set.iisInteger set bigger than 2**31.l(RR#R$t OverflowError(RtrlenRg((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt__len__²s 0  cCsx|ipdS|iddtjp|iddtjodSd}x'|iD]}||d|d7}qTW|S(s<Returns the length of this integer set as an integer. In case the length is infinite, returns -1. This function exists because of a limitation of the builtin len() function which expects values in the range 0 <= len < 2**31. Use this function in case your integer set might be larger.iiÿÿÿÿi(RR#R$(RRkRg((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyR Ãs 0 cCs t|iƒS(s<Returns true if this integer set contains at least one item.(RJR(R((s5/usr/lib/python2.6/site-packages/netaddr/ip/intset.pyt __nonzero__Ósccs(g}xÓ|iD]È}|dtjoS|dtjo#|iddgddgfƒqØ|i|dddgƒq|dtjo|i|ddgƒq|d}x%||djo|V|d7}q³WqW|oAx>to2x+|D]#}|dV|dc|d7s  ,