[PATCH 5/5] Separate code for finding item in containers combo and processing it

Vratislav Podzimek vpodzime at redhat.com
Fri Apr 11 09:28:11 UTC 2014


Also prevent traceback with found being used before being assigned to if there
is no matching item in the combobox.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/custom.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 4b6f4b9..d248ed8 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -1946,21 +1946,23 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         container_exists = getattr(container, "exists", False)
         found = None
 
+        # TODO: implement and use function for finding item in combobox
         for idx, data in enumerate(self._containerStore):
             # we're looking for the original vg name
             if data[0] == container_name:
-                c = self._storage_playground.devicetree.getDeviceByName(self._device_container_name)
-                freeSpace = getattr(c, "freeSpace", None)
-
-                self._containerStore.insert(idx, self._container_store_row(self._device_container_name, freeSpace))
-                self._containerCombo.set_active(idx)
-                self._modifyContainerButton.set_sensitive(not container_exists)
-
-                found = idx
                 break
+        else:
+            # no match found, just update selectors and return
+            self._update_selectors()
+            return
+
+        c = self._storage_playground.devicetree.getDeviceByName(self._device_container_name)
+        freeSpace = getattr(c, "freeSpace", None)
 
-        if found:
-            self._containerStore.remove(self._containerStore.get_iter_from_string("%s" % found))
+        self._containerStore.insert(idx, self._container_store_row(self._device_container_name, freeSpace))
+        self._containerCombo.set_active(idx)
+        self._modifyContainerButton.set_sensitive(not container_exists)
+        self._containerStore.remove(self._containerStore.get_iter_from_string("%s" % found))
 
         self._update_selectors()
 
-- 
1.9.0



More information about the anaconda-patches mailing list