[Pkg-privacy-commits] [pyptlib] 89/136: add default values to Config constructor so it's easier to instantiate in tests
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:25:13 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 20d779b4403995997e66bcafb09c816b4c3914d6
Author: Ximin Luo <infinity0 at gmx.com>
Date: Mon Aug 19 18:31:00 2013 +0100
add default values to Config constructor so it's easier to instantiate in tests
---
pyptlib/config.py | 7 +++++--
pyptlib/core.py | 4 +---
pyptlib/server_config.py | 11 ++++++++---
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/pyptlib/config.py b/pyptlib/config.py
index 2247b57..e9f70ab 100644
--- a/pyptlib/config.py
+++ b/pyptlib/config.py
@@ -5,8 +5,9 @@
Parts of pyptlib that are useful both to clients and servers.
"""
-import os, sys
+import os
+SUPPORTED_TRANSPORT_VERSIONS = ['1']
def env_has_k(k, v):
"""
@@ -33,7 +34,9 @@ class Config(object):
:var bool allTransportsEnabled: True if Tor wants us to spawn all the transports.
"""
- def __init__(self, stateLocation, managedTransportVer, transports):
+ def __init__(self, stateLocation,
+ managedTransportVer=SUPPORTED_TRANSPORT_VERSIONS,
+ transports=[]):
self.stateLocation = stateLocation
self.managedTransportVer = managedTransportVer
self.allTransportsEnabled = False
diff --git a/pyptlib/core.py b/pyptlib/core.py
index 9512d0f..99ee15d 100644
--- a/pyptlib/core.py
+++ b/pyptlib/core.py
@@ -1,8 +1,6 @@
import sys
-from pyptlib.config import EnvError
-
-SUPPORTED_TRANSPORT_VERSIONS = ['1']
+from pyptlib.config import EnvError, SUPPORTED_TRANSPORT_VERSIONS
class TransportPlugin(object):
diff --git a/pyptlib/server_config.py b/pyptlib/server_config.py
index 3e7fb86..0393b8b 100644
--- a/pyptlib/server_config.py
+++ b/pyptlib/server_config.py
@@ -9,7 +9,7 @@ import pyptlib.config as config
import pyptlib.util as util
import sys
-from pyptlib.config import env_has_k, env_id, get_env
+from pyptlib.config import env_has_k, env_id, get_env, SUPPORTED_TRANSPORT_VERSIONS
class ServerConfig(config.Config):
"""
@@ -85,8 +85,13 @@ class ServerConfig(config.Config):
authCookieFile = authCookieFile
)
- def __init__(self, stateLocation, managedTransportVer, transports,
- serverBindAddr, ORPort, extendedORPort, authCookieFile):
+ def __init__(self, stateLocation,
+ managedTransportVer=SUPPORTED_TRANSPORT_VERSIONS,
+ transports=[],
+ serverBindAddr={},
+ ORPort=None,
+ extendedORPort=None,
+ authCookieFile=None):
config.Config.__init__(self,
stateLocation, managedTransportVer, transports)
self.serverBindAddr = serverBindAddr
--
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