[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Change BridgeRequestBase.isValid() to allow setting the attribute.
commit 1cc15e8c0844c704f17502c063b2caf384977e06
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Fri Dec 5 23:50:11 2014 +0000
Change BridgeRequestBase.isValid() to allow setting the attribute.
The syntax is nicer with:
>>> bridgeRequest = bridgedb.bridgerequest.BridgeRequestBase()
>>> bridgeRequest.isValid()
False
>>> bridgeRequest.isValid(True)
>>> bridgeRequest.isValid()
True
than it was with the old implementation:
>>> bridgeRequest = bridgedb.bridgerequest.BridgeRequestBase()
>>> bridgeRequest.isValid()
False
>>> bridgeRequest.valid = True
>>> bridgeRequest.isValid()
True
---
lib/bridgedb/bridgerequest.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/bridgedb/bridgerequest.py b/lib/bridgedb/bridgerequest.py
index 7b2bfe9..3ef0dc7 100644
--- a/lib/bridgedb/bridgerequest.py
+++ b/lib/bridgedb/bridgerequest.py
@@ -82,8 +82,18 @@ class BridgeRequestBase(object):
self.notBlockedIn = list()
self.valid = False
- def isValid(self):
- pass
+ def isValid(self, valid=None):
+ """Set or determine if this request was valid.
+
+ :type valid: None or bool
+ :param valid: If ``None``, get the current request validity. If
+ ``True`` or ``False``, set the request validity accordingly.
+ :rtype: bool
+ :returns: Whether or not this request is valid.
+ """
+ if isinstance(valid, bool):
+ self.valid = valid
+ return self.valid
def withIPv4(self):
self.addressClass = ipaddr.IPv4Address
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits