commit f5adabe5392f0ec67079f8794ced9a6df487ca38 Author: Isis Lovecruft isis@torproject.org Date: Sun Jan 12 02:42:37 2014 +0000
Refactor PluggableTransport.getTransportLine() to remove `keyid=`.
* FIXES #10559 * FIXES a bunch of PEP8 problems. * CHANGE getTransportLine() to use `' '.join()` rather than formatting the bridge line inside the return statement. It's faster and safer. --- lib/bridgedb/Bridges.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py index dd0a7a9..cbc86f9 100644 --- a/lib/bridgedb/Bridges.py +++ b/lib/bridgedb/Bridges.py @@ -413,14 +413,23 @@ class PluggableTransport: :returns: A configuration line for adding this pluggable transport into a torrc file. """ - if isinstance(self.address,ipaddr.IPv6Address): - address = "[%s]" % self.address - else: address = self.address - host = "%s %s:%d" % (self.methodname, address, self.port) - fp = '' - if includeFingerprint: fp = "keyid=%s" % self.bridge.fingerprint - args = ",".join(["%s=%s"%(k,v) for k,v in self.argdict.items()]).strip() - return "%s %s %s" % (host, fp, args) + sections = [] + + + if isinstance(self.address, ipaddr.IPv6Address): + host = "%s [%s]:%d" % (self.methodname, self.address, self.port) + else: + host = "%s %s:%d" % (self.methodname, self.address, self.port) + sections.append(host) + + if includeFingerprint: + sections.append(self.bridge.fingerprint) + + args = ",".join(["%s=%s" % (k, v) for k, v in self.argdict.items()]) + sections.append(args) + + line = ' '.join(sections) + return line
def parseExtraInfoFile(f): """