[Pkg-privacy-commits] [pyptlib] 98/136: drop the distinction between "transports Tor wants" and "transports we support" - idea imported from previous API but is unnecessary and just adds complexity - instead, only expose the latter in the API
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:25:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository pyptlib.
commit f1e8c23e0cbf162596e67e3f001bb95611dc02f4
Author: Ximin Luo <infinity0 at gmx.com>
Date: Mon Sep 2 18:38:54 2013 +0100
drop the distinction between "transports Tor wants" and "transports we support"
- idea imported from previous API but is unnecessary and just adds complexity
- instead, only expose the latter in the API
---
pyptlib/client.py | 2 +-
pyptlib/core.py | 2 +-
pyptlib/server.py | 8 ++++----
pyptlib/server_config.py | 12 ------------
pyptlib/test/test_core.py | 14 +++++++-------
pyptlib/test/test_server.py | 2 +-
6 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/pyptlib/client.py b/pyptlib/client.py
index 03554ab..b4238a7 100644
--- a/pyptlib/client.py
+++ b/pyptlib/client.py
@@ -44,7 +44,7 @@ def init(supported_transports):
client.init(supported_transports)
retval = {}
retval['state_loc'] = client.config.getStateLocation()
- retval['transports'] = client.getServedTransports()
+ retval['transports'] = client.getTransports()
return retval
diff --git a/pyptlib/core.py b/pyptlib/core.py
index 4a290f3..980095a 100644
--- a/pyptlib/core.py
+++ b/pyptlib/core.py
@@ -87,7 +87,7 @@ class TransportPlugin(object):
self.served_version = wanted_versions[0]
self.served_transports = wanted_transports
- def getServedTransports(self):
+ def getTransports(self):
"""
:returns: list of names of the transports that this plugin can serve.
:raises: :class:`ValueError` if called before :func:`init`.
diff --git a/pyptlib/server.py b/pyptlib/server.py
index e6b5199..e529014 100644
--- a/pyptlib/server.py
+++ b/pyptlib/server.py
@@ -33,15 +33,15 @@ class ServerTransportPlugin(TransportPlugin):
self.emit('SMETHOD %s %s:%s' % (name, addrport[0],
addrport[1]))
- def getServedBindAddresses(self):
+ def getBindAddresses(self):
"""
:returns: dict of names of the transports that this plugin can serve,
each mapped to the (ip,port) where the transport should bind.
:raises: :class:`ValueError` if called before :func:`init`.
"""
return dict((k, v)
- for k, v in self.config.getServerBindAddresses().items()
- if k in self.getServedTransports())
+ for k, v in self.config.serverBindAddr.iteritems()
+ if k in self.getTransports())
def init(supported_transports):
@@ -53,7 +53,7 @@ def init(supported_transports):
retval['state_loc'] = config.getStateLocation()
retval['orport'] = config.getORPort()
retval['ext_orport'] = config.getExtendedORPort()
- retval['transports'] = server.getServedBindAddresses()
+ retval['transports'] = server.getBindAddresses()
retval['auth_cookie_file'] = config.getAuthCookieFile()
return retval
diff --git a/pyptlib/server_config.py b/pyptlib/server_config.py
index 495afa7..ac7ce5b 100644
--- a/pyptlib/server_config.py
+++ b/pyptlib/server_config.py
@@ -110,18 +110,6 @@ class ServerConfig(config.Config):
"""
return self.ORPort
- def getServerBindAddresses(self):
- """
- :returns: :attr:`pyptlib.server_config.ServerConfig.serverBindAddr`
- """
- return self.serverBindAddr
-
- def getServerTransports(self):
- """
- :returns: :attr:`pyptlib.config.Config.transports`
- """
- return self.transports
-
def getAuthCookieFile(self):
"""
:returns: :attr:`pyptlib.server_config.ServerConfig.authCookieFile`
diff --git a/pyptlib/test/test_core.py b/pyptlib/test/test_core.py
index 35f5367..b43af8b 100644
--- a/pyptlib/test/test_core.py
+++ b/pyptlib/test/test_core.py
@@ -58,19 +58,19 @@ class PluginCoreTestMixin(object):
"""Unknown transports"""
self.installTestConfig(transports="are,you,a,badfish,too?".split(","))
self.plugin._declareSupports(["not_any_of_above"])
- self.assertEmpty(self.plugin.getServedTransports())
+ self.assertEmpty(self.plugin.getTransports())
self.assertOutputLinesStartWith("VERSION ")
def test_declareSupports_partial(self):
"""Partial transports"""
self.installTestConfig(transports="are,you,a,badfish,too?".split(","))
self.plugin._declareSupports(["badfish", "not_any_of_above"])
- self.assertEquals(self.plugin.getServedTransports(), ["badfish"])
+ self.assertEquals(self.plugin.getTransports(), ["badfish"])
self.assertOutputLinesStartWith("VERSION ")
- def test_getServedTransports_noinit(self):
- """getServerTransports raises correctly."""
- self.assertRaises(ValueError, self.plugin.getServedTransports)
+ def test_getTransports_noinit(self):
+ """getTransports raises correctly."""
+ self.assertRaises(ValueError, self.plugin.getTransports)
def test_init_passthru_loadConfigFromEnv_error(self):
"""init passes-through errors from loadConfigFromEnv."""
@@ -79,10 +79,10 @@ class PluginCoreTestMixin(object):
self.assertOutputLinesStartWith("ENV-ERROR ")
def test_init_correct_servedTransports(self):
- """init results in correct getServerTransports."""
+ """init results in correct getTransports."""
self.installTestConfig(transports=["yeayeayea"])
self.plugin.init(["yeayeayea"])
- self.assertEquals(["yeayeayea"], self.plugin.getServedTransports())
+ self.assertEquals(["yeayeayea"], self.plugin.getTransports())
self.assertOutputLinesStartWith("VERSION ")
class DummyConfig(Config):
diff --git a/pyptlib/test/test_server.py b/pyptlib/test/test_server.py
index 1324b81..0497741 100644
--- a/pyptlib/test/test_server.py
+++ b/pyptlib/test/test_server.py
@@ -137,7 +137,7 @@ class testServer(PluginCoreTestMixin, unittest.TestCase):
"""Correct Extended ORPort configuration."""
os.environ = BASE_ENVIRON
self.plugin.init(["dummy", "boom"])
- bindaddr = self.plugin.getServedBindAddresses()
+ bindaddr = self.plugin.getBindAddresses()
self.assertEquals(bindaddr["dummy"], ('127.0.0.1', 5556))
self.assertEquals(bindaddr["boom"], ('127.0.0.1', 6666))
self.assertOutputLinesStartWith("VERSION ")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pyptlib.git
More information about the Pkg-privacy-commits
mailing list