[PATCH 02/15] Make the various DeviceAction.isFoo methods into properties.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pyanaconda/storage/deviceaction.py |   14 +++++++++++---
 pyanaconda/storage/devicetree.py   |   20 ++++++++++----------
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/pyanaconda/storage/deviceaction.py b/pyanaconda/storage/deviceaction.py
index 64e5d35..ca7b3bc 100644
--- a/pyanaconda/storage/deviceaction.py
+++ b/pyanaconda/storage/deviceaction.py
@@ -157,27 +157,35 @@ class DeviceAction(object):
         """ cancel the action """
         pass
 
+    @property
     def isDestroy(self):
         return self.type == ACTION_TYPE_DESTROY
 
+    @property
     def isCreate(self):
         return self.type == ACTION_TYPE_CREATE
 
+    @property
     def isMigrate(self):
         return self.type == ACTION_TYPE_MIGRATE
 
+    @property
     def isResize(self):
         return self.type == ACTION_TYPE_RESIZE
 
+    @property
     def isShrink(self):
         return (self.type == ACTION_TYPE_RESIZE and self.dir == RESIZE_SHRINK)
 
+    @property
     def isGrow(self):
         return (self.type == ACTION_TYPE_RESIZE and self.dir == RESIZE_GROW)
 
+    @property
     def isDevice(self):
         return self.obj == ACTION_OBJECT_DEVICE
 
+    @property
     def isFormat(self):
         return self.obj == ACTION_OBJECT_FORMAT
 
@@ -188,11 +196,11 @@ class DeviceAction(object):
     def __str__(self):
         s = "[%d] %s %s" % (self.id, action_strings[self.type],
                             object_strings[self.obj])
-        if self.isResize():
+        if self.isResize:
             s += " (%s)" % resize_strings[self.dir]
-        if self.isFormat():
+        if self.isFormat:
             s += " %s on" % self.format.type
-        if self.isMigrate():
+        if self.isMigrate:
             s += " to %s" % self.format.migrationTarget
         s += " %s %s (id %d)" % (self.device.type, self.device.name,
                                  self.device.id)
diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 088dc5a..8336476 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -781,11 +781,11 @@ class DeviceTree(object):
             Modifications to the Device instance are handled before we
             get here.
         """
-        if (action.isDestroy() or action.isResize() or \
-            (action.isCreate() and action.isFormat())) and \
+        if (action.isDestroy or action.isResize or \
+            (action.isCreate and action.isFormat)) and \
            action.device not in self._devices:
             raise DeviceTreeError("device is not in the tree")
-        elif (action.isCreate() and action.isDevice()):
+        elif (action.isCreate and action.isDevice):
             # this allows multiple create actions w/o destroy in between;
             # we will clean it up before processing actions
             #raise DeviceTreeError("device is already in the tree")
@@ -795,11 +795,11 @@ class DeviceTree(object):
                 if d.path == action.device.path:
                     self._removeDevice(d)
 
-        if action.isCreate() and action.isDevice():
+        if action.isCreate and action.isDevice:
             self._addDevice(action.device)
-        elif action.isDestroy() and action.isDevice():
+        elif action.isDestroy and action.isDevice:
             self._removeDevice(action.device)
-        elif action.isCreate() and action.isFormat():
+        elif action.isCreate and action.isFormat:
             if isinstance(action.device.format, formats.fs.FS) and \
                action.device.format.mountpoint in self.filesystems:
                 raise DeviceTreeError("mountpoint already in use")
@@ -816,14 +816,14 @@ class DeviceTree(object):
             Actions all operate on a Device, so we can use the devices
             to determine dependencies.
         """
-        if action.isCreate() and action.isDevice():
+        if action.isCreate and action.isDevice:
             # remove the device from the tree
             self._removeDevice(action.device)
-        elif action.isDestroy() and action.isDevice():
+        elif action.isDestroy and action.isDevice:
             # add the device back into the tree
             self._addDevice(action.device)
-        elif action.isFormat() and \
-             (action.isCreate() or action.isMigrate() or action.isResize()):
+        elif action.isFormat and \
+             (action.isCreate or action.isMigrate or action.isResize):
             action.cancel()
 
         self._actions.remove(action)
-- 
1.7.2.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux