[PATCH 3/7] Add a remove_check method for InputCheckHandler.

David Shea dshea at redhat.com
Tue Apr 15 18:22:28 UTC 2014


remove_check will reset the InputCheck status to OK and update the
InputCheckHandler, as well as removing it from the check list.

Also removed the InputCheck.set_status property since it's not actually
used.
---
 pyanaconda/ui/helpers.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/ui/helpers.py b/pyanaconda/ui/helpers.py
index fa9e77a..fda3e8b 100644
--- a/pyanaconda/ui/helpers.py
+++ b/pyanaconda/ui/helpers.py
@@ -218,8 +218,6 @@ class InputCheck(object):
                          doc="A function to call to perform the input check.")
     data = property(lambda s: s._data,
                     doc="Optional data associated with the input check.")
-    set_status = property(lambda s: s._set_status,
-                          doc="A function called when the status changes.")
     check_status = property(lambda s: s._check_status,
                             doc="The current status of the check")
 
@@ -356,6 +354,20 @@ class InputCheckHandler(object):
         return self.add_check(input_obj=input_obj, run_check=self._check_re,
                 data={'regex': regex, 'message': message})
 
+    def remove_check(self, inputcheck):
+        """Remove an input check.
+
+           If the check being removed is not in the OK status, the status will
+           be set to CHECK_OK and set_status will be called.
+
+           :param inputcheck InputCheck: the InputCheck object to remove
+           :raise ValueError: if the inputcheck does not exist for this InputCheckHandler
+        """
+        self._check_list.remove(inputcheck)
+        if inputcheck.check_status != InputCheck.CHECK_OK:
+            inputcheck._check_status = InputCheck.CHECK_OK
+            self.set_status(inputcheck)
+
     @property
     def failed_checks(self):
         """A generator of all failed input checks"""
-- 
1.9.0



More information about the anaconda-patches mailing list