commit 598ca5cb181938e816dd26b86edd8108d158c242 Author: Damian Johnson atagar@torproject.org Date: Mon Jan 15 09:01:09 2018 -0800
Rename an internal connection helper --- stem/exit_policy.py | 2 +- stem/util/connection.py | 8 ++++---- test/unit/util/connection.py | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/stem/exit_policy.py b/stem/exit_policy.py index fd8c15c2..4ef66666 100644 --- a/stem/exit_policy.py +++ b/stem/exit_policy.py @@ -910,7 +910,7 @@ class ExitPolicyRule(object): def _get_mask_bin(self): # provides an integer representation of our mask
- return int(stem.util.connection._get_address_binary(self.get_mask(False)), 2) + return int(stem.util.connection._address_to_binary(self.get_mask(False)), 2)
@lru_cache() def _get_address_bin(self): diff --git a/stem/util/connection.py b/stem/util/connection.py index 464a9ca1..d68c6124 100644 --- a/stem/util/connection.py +++ b/stem/util/connection.py @@ -558,7 +558,7 @@ def address_to_int(address): # TODO: Could be neat to also use this for serialization if we also had an # int_to_address() function.
- return int(_get_address_binary(address), 2) + return int(_address_to_binary(address), 2)
def expand_ipv6_address(address): @@ -597,7 +597,7 @@ def expand_ipv6_address(address): # # '5.9.158.75' => '0509:9e4b'
- ipv4_bin = _get_address_binary(address[ipv4_start:ipv4_end]) + ipv4_bin = _address_to_binary(address[ipv4_start:ipv4_end]) groupings = [ipv4_bin[16 * i:16 * (i + 1)] for i in range(2)] ipv6_snippet = ':'.join(['%04x' % int(group, 2) for group in groupings])
@@ -691,7 +691,7 @@ def _get_masked_bits(mask): raise ValueError("'%s' is an invalid subnet mask" % mask)
# converts octets to binary representation - mask_bin = _get_address_binary(mask) + mask_bin = _address_to_binary(mask) mask_match = re.match('^(1*)(0*)$', mask_bin)
if mask_match: @@ -713,7 +713,7 @@ def _get_binary(value, bits): return ''.join([str((value >> y) & 1) for y in range(bits - 1, -1, -1)])
-def _get_address_binary(address): +def _address_to_binary(address): """ Provides the binary value for an IPv4 or IPv6 address.
diff --git a/test/unit/util/connection.py b/test/unit/util/connection.py index 98d5c3f3..58a5cb82 100644 --- a/test/unit/util/connection.py +++ b/test/unit/util/connection.py @@ -602,9 +602,9 @@ class TestConnection(unittest.TestCase): self.assertRaises(ValueError, stem.util.connection._get_masked_bits, 'blarg') self.assertRaises(ValueError, stem.util.connection._get_masked_bits, '255.255.0.255')
- def test_get_address_binary(self): + def test_address_to_binary(self): """ - Checks the _get_address_binary function. + Checks the _address_to_binary function. """
test_values = { @@ -619,7 +619,7 @@ class TestConnection(unittest.TestCase): }
for test_arg, expected in test_values.items(): - self.assertEqual(expected, stem.util.connection._get_address_binary(test_arg)) + self.assertEqual(expected, stem.util.connection._address_to_binary(test_arg))
- self.assertRaises(ValueError, stem.util.connection._get_address_binary, '') - self.assertRaises(ValueError, stem.util.connection._get_address_binary, 'blarg') + self.assertRaises(ValueError, stem.util.connection._address_to_binary, '') + self.assertRaises(ValueError, stem.util.connection._address_to_binary, 'blarg')