[PATCH 3/4] Refactor out the code for bounding size into a function

Vratislav Podzimek vpodzime at redhat.com
Mon Apr 7 15:51:51 UTC 2014


In order to make the _save_right_side method shorter and less complex.

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

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 3a1f287..3fa8f83 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -690,6 +690,16 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         with ui_storage_logger():
             self._storage_playground.resetDevice(original_device)
 
+    def _bound_size(self, size, device):
+        # If no size was specified, we just want to grow to the maximum.
+        # But resizeDevice doesn't take None for a value.
+        if not size:
+            size = device.maxSize
+        elif size < device.minSize:
+            size = device.minSize
+        elif size > device.maxSize:
+            size = device.maxSize
+
     def _save_right_side(self, selector):
         """ Save settings from RHS and apply changes to the device.
 
@@ -976,15 +986,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             self._revert_reformat(device, use_dev)
 
         if changed_size and device.resizable:
-            # If no size was specified, we just want to grow to
-            # the maximum.  But resizeDevice doesn't take None for
-            # a value.
-            if not size:
-                size = device.maxSize
-            elif size < device.minSize:
-                size = device.minSize
-            elif size > device.maxSize:
-                size = device.maxSize
+            self._bound_size(size, device)
 
             # And then we need to re-check that the max size is actually
             # different from the current size.
-- 
1.9.0



More information about the anaconda-patches mailing list