[Pkg-privacy-commits] [pyptlib] 81/136: move allTransportsEnabled logic into parent Config class

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:25:12 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 4c81afebba0f82342013fc1f7efb32fa09cb738a
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Wed Aug 14 15:15:03 2013 +0100

    move allTransportsEnabled logic into parent Config class
---
 pyptlib/client_config.py | 8 ++------
 pyptlib/config.py        | 6 +++++-
 pyptlib/server_config.py | 9 +++------
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/pyptlib/client_config.py b/pyptlib/client_config.py
index 3099600..6cd6317 100644
--- a/pyptlib/client_config.py
+++ b/pyptlib/client_config.py
@@ -16,12 +16,8 @@ class ClientConfig(Config):
     :raises: :class:`pyptlib.config.EnvError` if environment was incomplete or corrupted.
     """
     def __init__(self):
-        Config.__init__(self)
-
-        self.transports = self.getEnv('TOR_PT_CLIENT_TRANSPORTS').split(',')
-        if '*' in self.transports:
-            self.allTransportsEnabled = True
-            self.transports.remove('*')
+        Config.__init__(self,
+            transports = self.getEnv('TOR_PT_CLIENT_TRANSPORTS').split(','))
 
     def writeMethod(self, name, socksVersion, addrport, args=None, optArgs=None):
         """
diff --git a/pyptlib/config.py b/pyptlib/config.py
index af15404..ea9600c 100644
--- a/pyptlib/config.py
+++ b/pyptlib/config.py
@@ -36,10 +36,14 @@ class Config(object):
     :raises: :class:`pyptlib.config.EnvError` if environment was incomplete or corrupted.
     """
 
-    def __init__(self):
+    def __init__(self, transports):
         self.stateLocation = self.getEnv('TOR_PT_STATE_LOCATION')
         self.managedTransportVer = self.getEnv('TOR_PT_MANAGED_TRANSPORT_VER').split(',')
         self.allTransportsEnabled = False
+        if '*' in transports:
+            self.allTransportsEnabled = True
+            transports.remove('*')
+        self.transports = transports
 
     def getStateLocation(self):
         """
diff --git a/pyptlib/server_config.py b/pyptlib/server_config.py
index 933f856..afeeaa6 100644
--- a/pyptlib/server_config.py
+++ b/pyptlib/server_config.py
@@ -28,8 +28,6 @@ class ServerConfig(config.Config):
         string as its value if it does not support the Extended
         ORPort.
         """
-        config.Config.__init__(self)
-
         def empty_or_valid_addr(k, v):
             v = env_has_k(k, v)
             if v == '': return None
@@ -71,10 +69,9 @@ class ServerConfig(config.Config):
             if t != b:
                 raise ValueError("Can't match transports with bind addresses (%s, %s)" % (t, b))
             return transports
-        self.transports = self.getEnv('TOR_PT_SERVER_TRANSPORTS', validate_transports)
-        if '*' in self.transports:
-            self.allTransportsEnabled = True
-            self.transports.remove('*')
+        transports = self.getEnv('TOR_PT_SERVER_TRANSPORTS', validate_transports)
+
+        config.Config.__init__(self, transports)
 
     def getExtendedORPort(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