[Pkg-privacy-commits] [txtorcon] 26/49: variable naming

Ximin Luo infinity0 at debian.org
Mon Oct 19 13:49:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository txtorcon.

commit ac5964b90ae8caa6480ac8f3efbd3a646e0a5505
Author: meejah <meejah at meejah.ca>
Date:   Sat Jun 20 23:29:38 2015 -0600

    variable naming
---
 test/test_endpoints.py | 20 ++++++++++----------
 txtorcon/endpoints.py  | 32 ++++++++++++++++----------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/test/test_endpoints.py b/test/test_endpoints.py
index 2a730c9..bedafaf 100644
--- a/test/test_endpoints.py
+++ b/test/test_endpoints.py
@@ -571,7 +571,7 @@ class TestTorClientEndpoint(unittest.TestCase):
         def FailTorSocksEndpointGenerator(*args, **kw):
             kw['failure'] = connectionRefusedFailure
             return FakeTorSocksEndpoint(*args, **kw)
-        endpoint = TorClientEndpoint('', 0, proxyEndpointGenerator=FailTorSocksEndpointGenerator)
+        endpoint = TorClientEndpoint('', 0, proxy_endpoint_generator=FailTorSocksEndpointGenerator)
         d = endpoint.connect(None)
         return self.assertFailure(d, ConnectionRefusedError)
 
@@ -585,7 +585,7 @@ class TestTorClientEndpoint(unittest.TestCase):
         endpoint = TorClientEndpoint(
             'invalid host', 0,
             socks_username='billy', socks_password='s333cure',
-            proxyEndpointGenerator=FailTorSocksEndpointGenerator)
+            proxy_endpoint_generator=FailTorSocksEndpointGenerator)
         d = endpoint.connect(None)
         return self.assertFailure(d, ConnectionRefusedError)
 
@@ -622,9 +622,9 @@ class TestTorClientEndpoint(unittest.TestCase):
         """
         def TorSocksEndpointGenerator(*args, **kw):
             return FakeTorSocksEndpoint(*args, **kw)
-        endpoint = TorClientEndpoint('', 0, proxyEndpointGenerator=TorSocksEndpointGenerator)
+        endpoint = TorClientEndpoint('', 0, proxy_endpoint_generator=TorSocksEndpointGenerator)
         endpoint.connect(None)
-        self.assertEqual(endpoint.torSocksEndpoint.transport.value(), '\x05\x01\x00')
+        self.assertEqual(endpoint.tor_socks_endpoint.transport.value(), '\x05\x01\x00')
 
     def test_good_port_retry(self):
         """
@@ -639,9 +639,9 @@ class TestTorClientEndpoint(unittest.TestCase):
                 kw['acceptPort'] = port
                 kw['failure']    = connectionRefusedFailure
                 return FakeTorSocksEndpoint(*args, **kw)
-            endpoint = TorClientEndpoint('', 0, proxyEndpointGenerator=TorSocksEndpointGenerator)
+            endpoint = TorClientEndpoint('', 0, proxy_endpoint_generator=TorSocksEndpointGenerator)
             endpoint.connect(None)
-            self.assertEqual(endpoint.torSocksEndpoint.transport.value(), '\x05\x01\x00')
+            self.assertEqual(endpoint.tor_socks_endpoint.transport.value(), '\x05\x01\x00')
 
     def test_bad_port_retry(self):
         """
@@ -653,7 +653,7 @@ class TestTorClientEndpoint(unittest.TestCase):
                 kw['acceptPort'] = port
                 kw['failure']    = connectionRefusedFailure
                 return FakeTorSocksEndpoint(*args, **kw)
-            endpoint = TorClientEndpoint('', 0, proxyEndpointGenerator=TorSocksEndpointGenerator)
+            endpoint = TorClientEndpoint('', 0, proxy_endpoint_generator=TorSocksEndpointGenerator)
             d = endpoint.connect(None)
             return self.assertFailure(d, ConnectionRefusedError)
 
@@ -666,9 +666,9 @@ class TestTorClientEndpoint(unittest.TestCase):
             kw['acceptPort'] = 6669
             kw['failure']    = connectionRefusedFailure
             return FakeTorSocksEndpoint(*args, **kw)
-        endpoint = TorClientEndpoint('', 0, proxyEndpointGenerator=TorSocksEndpointGenerator, socks_port=6669)
+        endpoint = TorClientEndpoint('', 0, proxy_endpoint_generator=TorSocksEndpointGenerator, socks_port=6669)
         endpoint.connect(None)
-        self.assertEqual(endpoint.torSocksEndpoint.transport.value(), '\x05\x01\x00')
+        self.assertEqual(endpoint.tor_socks_endpoint.transport.value(), '\x05\x01\x00')
 
     def test_bad_no_guess_socks_port(self):
         """
@@ -680,6 +680,6 @@ class TestTorClientEndpoint(unittest.TestCase):
             kw['acceptPort'] = 9050
             kw['failure']    = connectionRefusedFailure
             return FakeTorSocksEndpoint(*args, **kw)
-        endpoint = TorClientEndpoint('', 0, proxyEndpointGenerator=TorSocksEndpointGenerator, socks_port=6669)
+        endpoint = TorClientEndpoint('', 0, proxy_endpoint_generator=TorSocksEndpointGenerator, socks_port=6669)
         d = endpoint.connect(None)
         self.assertFailure(d, ConnectionRefusedError)
diff --git a/txtorcon/endpoints.py b/txtorcon/endpoints.py
index 070e7e8..7288b4d 100644
--- a/txtorcon/endpoints.py
+++ b/txtorcon/endpoints.py
@@ -605,7 +605,7 @@ class TorClientEndpoint(object):
 
     :param port: The tcp port or Tor Hidden Service port.
 
-    :param proxyEndpointGenerator: This is used for unit tests.
+    :param proxy_endpoint_generator: This is used for unit tests.
 
     :param socksPort:
        This optional argument lets the user specify which Tor SOCKS
@@ -618,63 +618,63 @@ class TorClientEndpoint(object):
     def __init__(self, host, port,
                  socks_hostname=None, socks_port=None,
                  socks_username=None, socks_password=None,
-                 proxyEndpointGenerator=default_tcp4_endpoint_generator):
+                 proxy_endpoint_generator=default_tcp4_endpoint_generator):
         if host is None or port is None:
             raise ValueError('host and port must be specified')
 
         self.host = host
         self.port = port
-        self.proxyEndpointGenerator = proxyEndpointGenerator
+        self.proxy_endpoint_generator = proxy_endpoint_generator
         self.socks_hostname = socks_hostname
         self.socks_port = socks_port
         self.socks_username = socks_username
         self.socks_password = socks_password
 
         if self.socks_port is None:
-            self.socks_port_iter = iter(self.socks_ports_to_try)
-            self.socksGuessingEnabled = True
+            self._socks_port_iter = iter(self.socks_ports_to_try)
+            self._socks_guessing_enabled = True
         else:
-            self.socksGuessingEnabled = False
+            self._socks_guessing_enabled = False
 
     def connect(self, protocolfactory):
         self.protocolfactory = protocolfactory
 
-        if self.socksGuessingEnabled:
-            self.socks_port = self.socks_port_iter.next()
+        if self._socks_guessing_enabled:
+            self.socks_port = self._socks_port_iter.next()
 
         d = self._try_connect()
         return d
 
     def _try_connect(self):
-        self.torSocksEndpoint = self.proxyEndpointGenerator(
+        self.tor_socks_endpoint = self.proxy_endpoint_generator(
             reactor,
             self.socks_hostname,
             self.socks_port
         )
 
         if self.socks_username is None or self.socks_password is None:
-            socks5ClientEndpoint = SOCKS5ClientEndpoint(
+            ep = SOCKS5ClientEndpoint(
                 self.host,
                 self.port,
-                self.torSocksEndpoint
+                self.tor_socks_endpoint
             )
         else:
-            socks5ClientEndpoint = SOCKS5ClientEndpoint(
+            ep = SOCKS5ClientEndpoint(
                 self.host,
                 self.port,
-                self.torSocksEndpoint,
+                self.tor_socks_endpoint,
                 methods=dict(login=(self.socks_username, self.socks_password))
             )
 
-        d = socks5ClientEndpoint.connect(self.protocolfactory)
-        if self.socksGuessingEnabled:
+        d = ep.connect(self.protocolfactory)
+        if self._socks_guessing_enabled:
             d.addErrback(self._retry_socks_port)
         return d
 
     def _retry_socks_port(self, failure):
         failure.trap(error.ConnectError)
         try:
-            self.socks_port = self.socks_port_iter.next()
+            self.socks_port = self._socks_port_iter.next()
         except StopIteration:
             return failure
         d = self._try_connect()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/txtorcon.git



More information about the Pkg-privacy-commits mailing list