Ñò u©¿Uc@s dZdefd„ƒYZdS(s! Class representing IP Addresses t IPAddresscBs§eZdZdZd d d„Zd„Zd„Zd„Ze eeƒZ e d„ƒZ e i d„ƒZ e ed„ƒZe d „ƒZd „Ze d „ƒZRS( s¤Simple class to represent IP addresses This implementation represents purely the IP. Netmask, if needed, should be represented by a second IPAddress. s0.0.0.0cCs(d|_d|_||_||_dS(N(tNonet_addresst_netmasktaddresstnetmask(tselfRR((s../ip_address.pyt__init__(s   cCs |iƒS(N(t get_address(R((s../ip_address.pyt__str__/scCsŠg}|idjo ti}n7x$|iD]}|it|ƒƒq-Wdi|ƒ}|iodt|iƒƒ}||S|SdS(s#Returns this IP address as a stringt.t/N( RRRtDEFAULTtappendtstrtjoinRtshorthand_netmask(RtsegmentsRtsegmentR((s../ip_address.pyR2s    cCs-|dj oti|ƒ}n||_dS(sSets this IPAddress' addressN(RRtconvert_addressR(RR((s../ip_address.pyt set_addressAs cCs|iS(s Get netmask(R(R((s../ip_address.pyRIscCs?|dj o%t|ƒ}ti|dtƒ}n||_dS(s Set netmaskt check_netmaskN(RRRRtTrueR(Rtnew_mask((s../ip_address.pyRNs  cCsvti|ƒ}t|ƒdjotdƒ‚n|o9ti|ƒ}d|idƒjotdƒ‚qrn|S(s Convert a string into an array of ints. Also serves as a validation function - strings not of the correct form will raise a ValueError is Bad lengtht1sNot a valid netmask(Rtincremental_checktlent ValueErrortas_binary_stringtlstrip(RRRtbin_rep((s../ip_address.pyRWscCs2dig}|D]}|t|ƒdq~ƒS(s¾Convert a set of 4 octets into its binary string representation For example, 255.255.255.0 becomes: 11111111 11111111 11111111 00000000 (without the spaces) ti(Rtbin(Rt_[1]tx((s../ip_address.pyRgscCsti|iƒ}|idƒS(sÂConvert a long form netmask into a short form (CIDR). e.g. 255.255.255.0 -> /24 The returned value is undefined for IPAddress's not representing valid netmasks. R(RRRtcount(Rt binary_rep((s../ip_address.pyRqscCsž|idƒ}g}t|ƒdjotdƒ‚nx_|D]W}|pq?nt|ƒ}|djp |djotdƒ‚q?|i|ƒq?W|S(s†Incrementally check an IP Address. Useful for checking a partial address, e.g., one that is partly typed into the UI R isToo many octetsiiÿs"Values should be between 0 and 255(tsplitRRtintR (RtipRRtint_seg((s../ip_address.pyR{s N(t__name__t __module__t__doc__R RRR RRtpropertyRRtsettert staticmethodtFalseRRRR(((s../ip_address.pyRs     N(R+tobjectR(((s../ip_address.pyts