Home | Trees | Indices | Help |
|
---|
|
List of IpRange objects.
Converts a list of dotted quad ip address and/or CIDR addresses into a list of IpRange objects. This list can perform ``in`` and ``not in`` tests and iterate all of the addresses in the range.
This can be used to convert django's conf.settings.INTERNAL_IPS list into a smart object which allows CIDR notation.
>>> private_range = ('192.168.0.1','192.168.255.255') >>> INTERNAL_IPS = IpRangeList('127.0.0.1','10/8', private_range) >>> '127.0.0.1' in INTERNAL_IPS True >>> '10.10.10.10' in INTERNAL_IPS True >>> '192.168.192.168' in INTERNAL_IPS True >>> '172.16.0.1' in INTERNAL_IPS False
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
>>> repr = IpRangeList('127.0.0.1', '10/8', '192.168/16').__repr__() >>> repr = eval(repr) >>> assert repr[0] == ('127.0.0.1', '127.0.0.1') >>> assert repr[1] == ('10.0.0.0', '10.255.255.255') >>> assert repr[2] == ('192.168.0.0', '192.168.255.255')
|
Implements membership test operators `in` and `not in` for the address range. >>> r = IpRangeList('127.0.0.1', '10/8', '192.168/16') >>> '127.0.0.1' in r True >>> '10.0.0.1' in r True >>> 2130706433 in r True >>> 'invalid' in r Traceback (most recent call last): ... TypeError: expected dotted-quad ip address or 32-bit integer Args: item: Dotted-quad ip address Returns: True if address is in range, False otherwise |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Jan 3 23:11:42 2012 | http://epydoc.sourceforge.net |