Home | Trees | Index | Help |
---|
Package PyFoam :: Package ThirdParty :: Module IPy :: Class IPint |
|
IP
Handling of IP addresses returning integers.
Use class IP instead because some features are not implemented for IPint.Method Summary | |
---|---|
Create an instance of an IP object. | |
Called by comparison operations. | |
Called to implement membership test operators. | |
Called to implement evaluation of self[key]. | |
Called for the key object for dictionary operations, and by the built-in function hash() Should return a 32-bit integer usable as a hash value for dictionary operations. | |
Return the length of an subnet. | |
All IPy objects should evaluate to true in boolean context. | |
Print a representation of the Object. | |
Dispatch to the prefered String Representation. | |
Return the broadcast (last) address of a network as an (long) integer. | |
Return the first / base / network addess as an (long) integer. | |
Return a description of the IP type ('PRIVATE', 'RESERVERD', etc). | |
Return the length of an subnet. | |
Return the base (first) address of a network as an (long) integer. | |
Return netmask as an integer. | |
Check if two IP address ranges overlap. | |
Returns Network Prefixlen. | |
Return a string representation as a binary value. | |
Return a string representation in compressed format using '::' Notation. | |
Return a string representation in decimal format. | |
Return a string representation in the non mangled format. | |
Return a string representation in hex format in lower case. | |
Return netmask as an string. | |
Return a string representation in the usual format. | |
Return the IP version of this Object. | |
Prints Prefixlen/Netmask. |
Method Details |
---|
__init__(self,
data,
ipversion=0)
|
__cmp__(self,
other)
|
__contains__(self,
item)
|
__getitem__(self,
key)
Called to implement evaluation of self[key].
|
__hash__(self)
Called for the key object for dictionary operations, and by the
built-in function hash() Should return a 32-bit integer usable as a
hash value for dictionary operations. The only required property is
that objects which compare equal have the same hash value
|
__len__(self)
|
__nonzero__(self)
All IPy objects should evaluate to true in boolean context.
Ordinarily, they do, but if handling a default route expressed as
0.0.0.0/0, the __len__() of the object becomes 0, which is used as the
boolean value of the object.
|
__repr__(self)
|
__str__(self)
|
broadcast(self)Return the broadcast (last) address of a network as an (long) integer. The same as IP[-1]. |
int(self)Return the first / base / network addess as an (long) integer. The same as IP[0].>>> "%X" % IP('10.0.0.0/8').int() 'A000000' |
iptype(self)Return a description of the IP type ('PRIVATE', 'RESERVERD', etc).>>> print IP('127.0.0.1').iptype() PRIVATE >>> print IP('192.168.1.1').iptype() PRIVATE >>> print IP('195.185.1.2').iptype() PUBLIC >>> print IP('::1').iptype() LOOPBACK >>> print IP('2001:0658:022a:cafe:0200::1').iptype() ASSIGNABLE RIPEThe type information for IPv6 is out of sync with reality. |
len(self)Return the length of an subnet.>>> print IP('195.185.1.0/28').len() 16 >>> print IP('195.185.1.0/24').len() 256 |
net(self)Return the base (first) address of a network as an (long) integer. |
netmask(self)Return netmask as an integer.>>> "%X" % IP('195.185.0.0/16').netmask().int() 'FFFF0000' |
overlaps(self, item)Check if two IP address ranges overlap. Returns 0 if the two ranged don't overlap, 1 if the given range overlaps at the end and -1 if it does at the beginning.>>> IP('192.168.0.0/23').overlaps('192.168.1.0/24') 1 >>> IP('192.168.0.0/23').overlaps('192.168.1.255') 1 >>> IP('192.168.0.0/23').overlaps('192.168.2.0') 0 >>> IP('192.168.1.0/24').overlaps('192.168.0.0/23') -1 |
prefixlen(self)Returns Network Prefixlen.>>> IP('10.0.0.0/8').prefixlen() 8 |
strBin(self, wantprefixlen=None)Return a string representation as a binary value.>>> print IP('127.0.0.1').strBin() 01111111000000000000000000000001 |
strCompressed(self, wantprefixlen=None)Return a string representation in compressed format using '::' Notation.>>> IP('127.0.0.1').strCompressed() '127.0.0.1' >>> IP('2001:0658:022a:cafe:0200::1').strCompressed() '2001:658:22a:cafe:200::1' >>> IP('ffff:ffff:ffff:ffff:ffff:f:f:fffc/127').strCompressed() 'ffff:ffff:ffff:ffff:ffff:f:f:fffc/127' |
strDec(self, wantprefixlen=None)Return a string representation in decimal format.>>> print IP('127.0.0.1').strDec() 2130706433 >>> print IP('2001:0658:022a:cafe:0200::1').strDec() 42540616829182469433547762482097946625 |
strFullsize(self, wantprefixlen=None)Return a string representation in the non mangled format.>>> print IP('127.0.0.1').strFullsize() 127.0.0.1 >>> print IP('2001:0658:022a:cafe:0200::1').strFullsize() 2001:0658:022a:cafe:0200:0000:0000:0001 |
strHex(self, wantprefixlen=None)Return a string representation in hex format in lower case.>>> IP('127.0.0.1').strHex() '0x7f000001' >>> IP('2001:0658:022a:cafe:0200::1').strHex() '0x20010658022acafe0200000000000001' |
strNetmask(self)Return netmask as an string. Mostly useful for IPv6.>>> print IP('195.185.0.0/16').strNetmask() 255.255.0.0 >>> print IP('2001:0658:022a:cafe::0/64').strNetmask() /64 |
strNormal(self, wantprefixlen=None)Return a string representation in the usual format.>>> print IP('127.0.0.1').strNormal() 127.0.0.1 >>> print IP('2001:0658:022a:cafe:0200::1').strNormal() 2001:658:22a:cafe:200:0:0:1 |
version(self)Return the IP version of this Object.>>> IP('10.0.0.0/8').version() 4 >>> IP('::1').version() 6 |
_printPrefix(self, want)Prints Prefixlen/Netmask. Not really. In fact it is our universal Netmask/Prefixlen printer. This is considered an internel function. want == 0 / None don't return anything 1.2.3.0 want == 1 /prefix 1.2.3.0/24 want == 2 /netmask 1.2.3.0/255.255.255.0 want == 3 -lastip 1.2.3.0-1.2.3.255 |
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Mon Jan 22 23:52:48 2007 | http://epydoc.sf.net |