commit 772849f87da3a8d9cd256896e70ae46f0f435dc4 Author: Isis Lovecruft isis@torproject.org Date: Tue Mar 31 01:08:11 2015 +0000
Improve documentation of Dist.uniformMap(). --- lib/bridgedb/Dist.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/bridgedb/Dist.py b/lib/bridgedb/Dist.py index a71d6bb..a454a77 100644 --- a/lib/bridgedb/Dist.py +++ b/lib/bridgedb/Dist.py @@ -49,14 +49,17 @@ class EmailRequestedKey(Exception):
def uniformMap(ip): - """Map an IP to an arbitrary 'area' string, such that any two /24 addresses - get the same string. + """Map an IP to an arbitrary 'area' string, such that any two IPv4 + addresses in the same ``/24`` subnet, or any two IPv6 addresses in the + same ``/64`` subnet, get the same string.
>>> from bridgedb import Dist >>> Dist.uniformMap('1.2.3.4') '1.2.3'
:param str ip: A string representing an IPv4 or IPv6 address. + :rtype: str + :returns: The truncated **ip**. """ if type(IPAddress(ip)) is IPv6Address: return ":".join(IPv6Address(ip).exploded.split(':')[:4])