PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` netaddr.ip.sets.IPSet
Package netaddr :: Package ip :: Module sets :: Class IPSet
[hide private]
[frames] | no frames]

Class IPSet

object --+
         |
        IPSet

Represents an unordered collection (set) of unique IP addresses and subnets.

Instance Methods [hide private]
 
__init__(self, iterable=None, flags=0)
Constructor.
 
__getstate__(self)
Returns: Pickled state of an IPSet object.
 
__setstate__(self, state)
 
compact(self)
Compact internal list of IPNetwork objects using a CIDR merge.
 
__hash__(self)
Please Note: IPSet objects are not hashable and cannot be used as dictionary keys or as members of other sets.
 
__contains__(self, ip)
Returns: True if IP address or subnet is a member of this IP set.
 
__iter__(self)
Returns: an iterator over the IP addresses within this IP set.
 
iter_cidrs(self)
Returns: an iterator over individual IP subnets within this IP set.
 
add(self, addr, flags=0)
Adds an IP address or subnet to this IP set.
 
remove(self, addr, flags=0)
Removes an IP address or subnet from this IP set.
 
pop(self)
Removes and returns an arbitrary IP address or subnet from this IP set.
 
isdisjoint(self, other)
Returns: True if this IP set has no elements (IP addresses or subnets) in common with other.
 
copy(self)
Returns: a shallow copy of this IP set.
 
update(self, iterable, flags=0)
Update the contents of this IP set with the union of itself and other IP set.
 
clear(self)
Remove all IP addresses and subnets from this IP set.
 
__eq__(self, other)
Returns: True if this IP set is equivalent to the other IP set, False otherwise.
 
__ne__(self, other)
Returns: False if this IP set is equivalent to the other IP set, True otherwise.
 
__lt__(self, other)
Returns: True if this IP set is less than the other IP set, False otherwise.
 
issubset(self, other)
Returns: True if every IP address and subnet in this IP set is found within other.
 
__le__(self, other)
Returns: True if every IP address and subnet in this IP set is found within other.
 
__gt__(self, other)
Returns: True if this IP set is greater than the other IP set, False otherwise.
 
issuperset(self, other)
Returns: True if every IP address and subnet in other IP set is found within this one.
 
__ge__(self, other)
Returns: True if every IP address and subnet in other IP set is found within this one.
 
union(self, other)
Returns: the union of this IP set and another as a new IP set (combines IP addresses and subnets from both sets).
 
__or__(self, other)
Returns: the union of this IP set and another as a new IP set (combines IP addresses and subnets from both sets).
 
intersection(self, other)
Returns: the intersection of this IP set and another as a new IP set.
 
__and__(self, other)
Returns: the intersection of this IP set and another as a new IP set.
 
symmetric_difference(self, other)
Returns: the symmetric difference of this IP set and another as a new IP set (all IP addresses and subnets that are in exactly one of the sets).
 
__xor__(self, other)
Returns: the symmetric difference of this IP set and another as a new IP set (all IP addresses and subnets that are in exactly one of the sets).
 
difference(self, other)
Returns: the difference between this IP set and another as a new IP set (all IP addresses and subnets that are in this IP set but not found in the other.)
 
__sub__(self, other)
Returns: the difference between this IP set and another as a new IP set (all IP addresses and subnets that are in this IP set but not found in the other.)
 
__len__(self)
Returns: the cardinality of this IP set (i.e.
 
__repr__(self)
Returns: Python statement to create an equivalent object
 
__str__(self)
Returns: Python statement to create an equivalent object

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  size
The cardinality of this IP set (based on the number of individual IP addresses including those implicitly defined in subnets).
  _cidrs

Inherited from object: __class__

Method Details [hide private]

__init__(self, iterable=None, flags=0)
(Constructor)

 

Constructor.

Parameters:
  • iterable - (optional) an iterable containing IP addresses and subnets.
  • flags - decides which rules are applied to the interpretation of the addr value. See the netaddr.core namespace documentation for supported constant values.
Overrides: object.__init__

__getstate__(self)

 
Returns:
Pickled state of an IPSet object.

__setstate__(self, state)

 
Parameters:
  • state - data used to unpickle a pickled IPSet object.

__hash__(self)
(Hashing function)

 

Please Note: IPSet objects are not hashable and cannot be used as dictionary keys or as members of other sets. Raises TypeError if this method is called.

Overrides: object.__hash__

__contains__(self, ip)
(In operator)

 
Parameters:
  • ip - An IP address or subnet.
Returns:
True if IP address or subnet is a member of this IP set.

__iter__(self)

 
Returns:
an iterator over the IP addresses within this IP set.

iter_cidrs(self)

 
Returns:
an iterator over individual IP subnets within this IP set.

add(self, addr, flags=0)

 

Adds an IP address or subnet to this IP set. Has no effect if it is already present.

Note that where possible the IP address or subnet is merged with other members of the set to form more concise CIDR blocks.

Parameters:
  • addr - An IP address or subnet.
  • flags - decides which rules are applied to the interpretation of the addr value. See the netaddr.core namespace documentation for supported constant values.

remove(self, addr, flags=0)

 

Removes an IP address or subnet from this IP set. Does nothing if it is not already a member.

Note that this method behaves more like discard() found in regular Python sets because it doesn't raise KeyError exceptions if the IP address or subnet is question does not exist. It doesn't make sense to fully emulate that behaviour here as IP sets contain groups of individual IP addresses as individual set members using IPNetwork objects.

Parameters:
  • addr - An IP address or subnet.
  • flags - decides which rules are applied to the interpretation of the addr value. See the netaddr.core namespace documentation for supported constant values.

pop(self)

 

Removes and returns an arbitrary IP address or subnet from this IP set.

Returns:
An IP address or subnet.

isdisjoint(self, other)

 
Parameters:
  • other - an IP set.
Returns:
True if this IP set has no elements (IP addresses or subnets) in common with other. Intersection *must* be an empty set.

copy(self)

 
Returns:
a shallow copy of this IP set.

update(self, iterable, flags=0)

 

Update the contents of this IP set with the union of itself and other IP set.

Parameters:
  • iterable - an iterable containing IP addresses and subnets.
  • flags - decides which rules are applied to the interpretation of the addr value. See the netaddr.core namespace documentation for supported constant values.

__eq__(self, other)
(Equality operator)

 
Parameters:
  • other - an IP set
Returns:
True if this IP set is equivalent to the other IP set, False otherwise.

__ne__(self, other)

 
Parameters:
  • other - an IP set
Returns:
False if this IP set is equivalent to the other IP set, True otherwise.

__lt__(self, other)
(Less-than operator)

 
Parameters:
  • other - an IP set
Returns:
True if this IP set is less than the other IP set, False otherwise.

issubset(self, other)

 
Parameters:
  • other - an IP set.
Returns:
True if every IP address and subnet in this IP set is found within other.

__le__(self, other)
(Less-than-or-equals operator)

 
Parameters:
  • other - an IP set.
Returns:
True if every IP address and subnet in this IP set is found within other.

__gt__(self, other)
(Greater-than operator)

 
Parameters:
  • other - an IP set.
Returns:
True if this IP set is greater than the other IP set, False otherwise.

issuperset(self, other)

 
Parameters:
  • other - an IP set.
Returns:
True if every IP address and subnet in other IP set is found within this one.

__ge__(self, other)
(Greater-than-or-equals operator)

 
Parameters:
  • other - an IP set.
Returns:
True if every IP address and subnet in other IP set is found within this one.

union(self, other)

 
Parameters:
  • other - an IP set.
Returns:
the union of this IP set and another as a new IP set (combines IP addresses and subnets from both sets).

__or__(self, other)
(Or operator)

 
Parameters:
  • other - an IP set.
Returns:
the union of this IP set and another as a new IP set (combines IP addresses and subnets from both sets).

intersection(self, other)

 
Parameters:
  • other - an IP set.
Returns:
the intersection of this IP set and another as a new IP set. (IP addresses and subnets common to both sets).

__and__(self, other)
(And operator)

 
Parameters:
  • other - an IP set.
Returns:
the intersection of this IP set and another as a new IP set. (IP addresses and subnets common to both sets).

symmetric_difference(self, other)

 
Parameters:
  • other - an IP set.
Returns:
the symmetric difference of this IP set and another as a new IP set (all IP addresses and subnets that are in exactly one of the sets).

__xor__(self, other)
(Exclusive-Or operator)

 
Parameters:
  • other - an IP set.
Returns:
the symmetric difference of this IP set and another as a new IP set (all IP addresses and subnets that are in exactly one of the sets).

difference(self, other)

 
Parameters:
  • other - an IP set.
Returns:
the difference between this IP set and another as a new IP set (all IP addresses and subnets that are in this IP set but not found in the other.)

__sub__(self, other)
(Subtraction operator)

 
Parameters:
  • other - an IP set.
Returns:
the difference between this IP set and another as a new IP set (all IP addresses and subnets that are in this IP set but not found in the other.)

__len__(self)
(Length operator)

 
Returns:
the cardinality of this IP set (i.e. sum of individual IP addresses). Raises IndexError if size > maxint (a Python limitation). Use the .size property for subnets of any size.

__repr__(self)
(Representation operator)

 

str(x)

Returns:
Python statement to create an equivalent object
Overrides: object.__repr__

__str__(self)
(Informal representation operator)

 

str(x)

Returns:
Python statement to create an equivalent object
Overrides: object.__str__

Property Details [hide private]

size

The cardinality of this IP set (based on the number of individual IP addresses including those implicitly defined in subnets).

Get Method:
unreachable.size(self) - The cardinality of this IP set (based on the number of individual IP addresses including those implicitly defined in subnets).