[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Generalise BridgeRequestBase.isValid().



commit 7ebd8914e30fea061ecf6b537bb186660946db18
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Apr 2 05:00:56 2015 +0000

    Generalise BridgeRequestBase.isValid().
    
    It's now suitable for inheritance by email.request and https.request, so
    we can remove the custom methods from both.
---
 lib/bridgedb/bridgerequest.py |   17 +++++++++--------
 lib/bridgedb/email/request.py |   15 ---------------
 2 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/lib/bridgedb/bridgerequest.py b/lib/bridgedb/bridgerequest.py
index f653450..f7aa031 100644
--- a/lib/bridgedb/bridgerequest.py
+++ b/lib/bridgedb/bridgerequest.py
@@ -130,16 +130,17 @@ class BridgeRequestBase(object):
         return position
 
     def isValid(self, valid=None):
-        """Set or determine if this request was valid.
+        """Get or set the validity of this bridge request.
 
-        :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 called without parameters, this method will return the current
+        state, otherwise (if called with the **valid** parameter), it will set
+        the current state of validity for this request.
+
+        :param bool valid: If given, set the validity state of this
+            request. Otherwise, get the current state.
         """
-        if isinstance(valid, bool):
-            self.valid = valid
+        if valid is not None:
+            self.valid = bool(valid)
         return self.valid
 
     def withIPv4(self):
diff --git a/lib/bridgedb/email/request.py b/lib/bridgedb/email/request.py
index 9c0f0c2..32446ac 100644
--- a/lib/bridgedb/email/request.py
+++ b/lib/bridgedb/email/request.py
@@ -108,23 +108,8 @@ class EmailBridgeRequest(bridgerequest.BridgeRequestBase):
         :class:`~bridgedb.Dist.EmailBasedDistributor`.
         """
         super(EmailBridgeRequest, self).__init__()
-        self._isValid = False
         self._wantsKey = False
 
-    def isValid(self, valid=None):
-        """Get or set the validity of this bridge request.
-
-        If called without parameters, this method will return the current
-        state, otherwise (if called with the **valid** parameter), it will set
-        the current state of validity for this request.
-
-        :param bool valid: If given, set the validity state of this
-            request. Otherwise, get the current state.
-        """
-        if valid is not None:
-            self._isValid = bool(valid)
-        return self._isValid
-
     def wantsKey(self, wantsKey=None):
         """Get or set whether this bridge request wanted our GnuPG key.
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits