Module ipaddr :: Class BaseIP
[show private | hide private]
[frames | no frames]

Type BaseIP

object --+
         |
        BaseIP

Known Subclasses:
IPv4, IPv6

A generic IP object.

This IP class contains most of the methods which are used by the IPv4 and IPv6 classes.
Method Summary
  __cmp__(self, other)
  __contains__(self, other)
Return True if other is contained by self.
  __eq__(self, other)
  __getitem__(self, n)
  __hash__(self)
  __hex__(self)
  __int__(self)
  __ne__(self, other)
  __repr__(self)
  __str__(self)
  AddressExclude(self, other)
Remove an address from a larger block.
  CompareNetworks(self, other)
Compare two IP objects.
  Contains(self, other)
Return True if other is contained by self.
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  broadcast
  broadcast_ext
  hostmask
  hostmask_ext
  ip_ext
  ip_ext_full
  netmask_ext
  network
  network_ext
  numhosts
  version

Method Details

__contains__(self, other)
(In operator)

Return True if other is contained by self.

Args:
    other: An IP object.

Returns:
    A boolean.

AddressExclude(self, other)

Remove an address from a larger block.

For example:

    addr1 = IP('10.1.1.0/24')
    addr2 = IP('10.1.1.0/26')
    addr1.AddressExclude(addr2) =
        [IP('10.1.1.64/26'), IP('10.1.1.128/25')]

or IPv6:

    addr1 = IP('::1/32')
    addr2 = IP('::1/128')
    addr1.AddressExclude(addr2) = [IP('::0/128'),
        IP('::2/127'),
        IP('::4/126'),
        IP('::8/125'),
        ...
        IP('0:0:8000::/33')]

Args:
    other: An IP object of the same type.

Returns:
    A sorted list of IP objects addresses which is self minus
    other.

Raises:
    IPTypeError: If self and other are of difffering address
      versions.
    IPAddressExclusionError: There was some unknown error in the
      address exclusion process.  This likely points to a bug
      elsewhere in this code.
    ValueError: If other is not completely contained by self.

CompareNetworks(self, other)

Compare two IP objects.

This is only concerned about the comparison of the integer
representation of the network addresses.  This means that the
host bits aren't considered at all in this method.  If you want
to compare host bits, you can easily enough do a
'HostA.ip < HostB.ip'

Args:
    other: An IP object.

Returns:
    If the IP versions of self and other are the same, returns:

    -1 if self < other:
      eg: IPv4('1.1.1.0/24') < IPv4('1.1.2.0/24')
      IPv6('1080::200C:417A') < IPv6('1080::200B:417B')
    0 if self == other
      eg: IPv4('1.1.1.1/24') == IPv4('1.1.1.2/24')
      IPv6('1080::200C:417A/96') == IPv6('1080::200C:417B/96')
    1 if self > other
      eg: IPv4('1.1.1.0/24') > IPv4('1.1.0.0/24')
      IPv6('1080::1:200C:417A/112') >
      IPv6('1080::0:200C:417A/112')

    If the IP versions of self and other are different, returns:

    -1 if self.version < other.version
      eg: IPv4('10.0.0.1/24') < IPv6('::1/128')
    1 if self.version > other.version
      eg: IPv6('::1/128') > IPv4('255.255.255.0/24')

Contains(self, other)

Return True if other is contained by self.

Args:
    other: An IP object.

Returns:
    A boolean.

Property Details

broadcast

Get Method:
broadcast(...)

broadcast_ext

Get Method:
broadcast_ext(...)

hostmask

Get Method:
hostmask(...)

hostmask_ext

Get Method:
hostmask_ext(...)

ip_ext

Get Method:
ip_ext(...)

ip_ext_full

Get Method:
ip_ext_full(...)

netmask_ext

Get Method:
netmask_ext(...)

network

Get Method:
network(...)

network_ext

Get Method:
network_ext(...)

numhosts

Get Method:
numhosts(...)

version

Get Method:
version(...)

Generated by Epydoc 2.1 on Tue Feb 3 11:02:37 2009 http://epydoc.sf.net