[Pkg-privacy-commits] [pyptlib] 96/136: fix most pylint warnings

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 8c7a8b2e8238f9577d3c53ba21011ffed0935d24
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Mon Sep 2 15:30:26 2013 +0100

    fix most pylint warnings
---
 pyptlib/client_config.py    |  2 --
 pyptlib/config.py           |  9 +++++----
 pyptlib/core.py             |  7 ++++++-
 pyptlib/server_config.py    | 20 ++++++++++----------
 pyptlib/test/test_client.py |  4 ++--
 pyptlib/test/test_core.py   |  2 +-
 pyptlib/test/test_server.py |  4 ++--
 7 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/pyptlib/client_config.py b/pyptlib/client_config.py
index 003f24e..ced4dcd 100644
--- a/pyptlib/client_config.py
+++ b/pyptlib/client_config.py
@@ -5,8 +5,6 @@
 Low-level parts of pyptlib that are only useful to clients.
 """
 
-import sys
-
 from pyptlib.config import Config, get_env
 
 class ClientConfig(Config):
diff --git a/pyptlib/config.py b/pyptlib/config.py
index e9f70ab..7106d97 100644
--- a/pyptlib/config.py
+++ b/pyptlib/config.py
@@ -17,7 +17,7 @@ def env_has_k(k, v):
     if v is None: raise ValueError('Missing environment variable %s' % k)
     return v
 
-def env_id(k, v):
+def env_id(_, v):
     """
     A validator for Config.getEnv that returns the value of the envvar if it
     was found, or None if it was not.
@@ -35,10 +35,11 @@ class Config(object):
     """
 
     def __init__(self, stateLocation,
-                 managedTransportVer=SUPPORTED_TRANSPORT_VERSIONS,
-                 transports=[]):
+                 managedTransportVer=None,
+                 transports=None):
         self.stateLocation = stateLocation
-        self.managedTransportVer = managedTransportVer
+        self.managedTransportVer = managedTransportVer or SUPPORTED_TRANSPORT_VERSIONS
+        transports = transports or []
         self.allTransportsEnabled = False
         if '*' in transports:
             self.allTransportsEnabled = True
diff --git a/pyptlib/core.py b/pyptlib/core.py
index 824c333..a1b785a 100644
--- a/pyptlib/core.py
+++ b/pyptlib/core.py
@@ -12,9 +12,13 @@ class TransportPlugin(object):
 
     :var pyptlib.config.Config config: Configuration passed from Tor.
     :var file stdout: Output file descriptor to send status messages to.
+    :var str served_version: Version used by the plugin.
     :var list served_transports: List of transports served by the plugin,
             populated by init().
     """
+    configType = None
+    methodName = None
+
     def __init__(self, config=None, stdout=sys.stdout):
         self.config = config
         self.stdout = stdout
@@ -56,7 +60,7 @@ class TransportPlugin(object):
             self.emit('ENV-ERROR %s' % str(e))
             raise e
 
-    def _declareSupports(self, transports, versions=SUPPORTED_TRANSPORT_VERSIONS):
+    def _declareSupports(self, transports, versions=None):
         """
         Declare to Tor the versions and transports that this PT supports.
 
@@ -65,6 +69,7 @@ class TransportPlugin(object):
         """
         cfg = self.config
 
+        versions = versions or SUPPORTED_TRANSPORT_VERSIONS
         wanted_versions = [v for v in versions if v in cfg.managedTransportVer]
         if not wanted_versions:
             self.emit('VERSION-ERROR no-version')
diff --git a/pyptlib/server_config.py b/pyptlib/server_config.py
index 0393b8b..953df60 100644
--- a/pyptlib/server_config.py
+++ b/pyptlib/server_config.py
@@ -7,9 +7,8 @@ Low-level parts of pyptlib that are only useful to servers.
 
 import pyptlib.config as config
 import pyptlib.util as util
-import sys
 
-from pyptlib.config import env_has_k, env_id, get_env, SUPPORTED_TRANSPORT_VERSIONS
+from pyptlib.config import env_has_k, get_env, SUPPORTED_TRANSPORT_VERSIONS
 
 class ServerConfig(config.Config):
     """
@@ -42,11 +41,11 @@ class ServerConfig(config.Config):
         # Check that either both Extended ORPort and the Extended
         # ORPort Authentication Cookie are present, or neither.
         if extendedORPort:
-            def validate_authcookie(k, v):
+            def validate_authcookie(_, v):
                 if v is None: raise ValueError("Extended ORPort address provided, but no cookie file.")
                 return v
         else:
-            def validate_authcookie(k, v):
+            def validate_authcookie(_, v):
                 if v is not None: raise ValueError("Extended ORPort Authentication cookie file provided, but no Extended ORPort address.")
                 return v
         authCookieFile = get_env('TOR_PT_AUTH_COOKIE_FILE', validate_authcookie)
@@ -86,15 +85,16 @@ class ServerConfig(config.Config):
             )
 
     def __init__(self, stateLocation,
-                 managedTransportVer=SUPPORTED_TRANSPORT_VERSIONS,
-                 transports=[],
-                 serverBindAddr={},
+                 managedTransportVer=None,
+                 transports=None,
+                 serverBindAddr=None,
                  ORPort=None,
                  extendedORPort=None,
                  authCookieFile=None):
-        config.Config.__init__(self,
-            stateLocation, managedTransportVer, transports)
-        self.serverBindAddr = serverBindAddr
+        config.Config.__init__(self, stateLocation,
+            managedTransportVer or SUPPORTED_TRANSPORT_VERSIONS,
+            transports or [])
+        self.serverBindAddr = serverBindAddr or {}
         self.ORPort = ORPort
         self.extendedORPort = extendedORPort
         self.authCookieFile = authCookieFile
diff --git a/pyptlib/test/test_client.py b/pyptlib/test/test_client.py
index ebb6ca2..cac5772 100644
--- a/pyptlib/test/test_client.py
+++ b/pyptlib/test/test_client.py
@@ -3,9 +3,9 @@ import unittest
 
 from pyptlib.client import ClientTransportPlugin
 from pyptlib.config import EnvError, Config
-from pyptlib.test.test_core import PluginCoreTest
+from pyptlib.test.test_core import PluginCoreTestMixin
 
-class testClient(PluginCoreTest, unittest.TestCase):
+class testClient(PluginCoreTestMixin, unittest.TestCase):
     pluginType = ClientTransportPlugin
 
     def test_fromEnv_legit(self):
diff --git a/pyptlib/test/test_core.py b/pyptlib/test/test_core.py
index ad84ae4..35f5367 100644
--- a/pyptlib/test/test_core.py
+++ b/pyptlib/test/test_core.py
@@ -5,7 +5,7 @@ from cStringIO import StringIO
 
 from pyptlib.config import EnvError, Config
 
-class PluginCoreTest(object):
+class PluginCoreTestMixin(object):
     """
     This class is not a TestCase but is meant to be mixed-into tests
     for subclasses of TransportPlugin.
diff --git a/pyptlib/test/test_server.py b/pyptlib/test/test_server.py
index bdeb923..1324b81 100644
--- a/pyptlib/test/test_server.py
+++ b/pyptlib/test/test_server.py
@@ -3,7 +3,7 @@ import unittest
 
 from pyptlib.config import EnvError, Config
 from pyptlib.server import ServerTransportPlugin
-from pyptlib.test.test_core import PluginCoreTest
+from pyptlib.test.test_core import PluginCoreTestMixin
 from pyptlib.core import SUPPORTED_TRANSPORT_VERSIONS
 
 # a good valid environment to base modifications from
@@ -17,7 +17,7 @@ BASE_ENVIRON = {
     "TOR_PT_SERVER_TRANSPORTS" : "dummy,boom"
 }
 
-class testServer(PluginCoreTest, unittest.TestCase):
+class testServer(PluginCoreTestMixin, unittest.TestCase):
     pluginType = ServerTransportPlugin
 
     def test_fromEnv_legit(self):

-- 
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