[blivet:rhel7/master 2/6] Make DeviceFormat.supported a class method (#1065422)

mulhern amulhern at redhat.com
Sat Feb 15 18:52:27 UTC 2014


Related: rhbz#1065422

This really should be a class method as well, and it relies on utilsAvailable()
frequently, which makes this more obvious.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/__init__.py         |  2 +-
 blivet/formats/__init__.py | 12 ++++++------
 blivet/formats/biosboot.py |  4 ++--
 blivet/formats/fs.py       | 46 +++++++++++++++++++++++-----------------------
 blivet/formats/prepboot.py |  4 ++--
 5 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index 6908b2a..9b3ff44 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -1778,7 +1778,7 @@ class Blivet(object):
         if fmt.type is None:
             raise ValueError("unrecognized value %s for new default fs type" % newtype)
 
-        if (not fmt.mountable or not fmt.formattable or not fmt.supported or
+        if (not fmt.mountable or not fmt.formattable or not fmt.supported() or
             not fmt.linuxNative):
             log.debug("invalid default fstype: %r" % fmt)
             raise ValueError("new value %s is not valid as a default fs type" % fmt)
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py
index be00da4..2b3d183 100644
--- a/blivet/formats/__init__.py
+++ b/blivet/formats/__init__.py
@@ -52,7 +52,7 @@ default_fstypes = ("ext4", "ext3", "ext2")
 def get_default_filesystem_type():
     for fstype in default_fstypes:
         try:
-            supported = get_device_format_class(fstype).supported
+            supported = get_device_format_class(fstype).supported()
         except AttributeError:
             supported = None
 
@@ -191,7 +191,7 @@ class DeviceFormat(object):
              {"classname": self.__class__.__name__, "id": "%#x" % id(self),
               "type": self.type, "name": self.name, "status": self.status,
               "device": self.device, "uuid": self.uuid, "exists": self.exists,
-              "options": self.options, "supported": self.supported,
+              "options": self.options, "supported": self.supported(),
               "format": self.formattable, "resize": self.resizable})
         return s
 
@@ -213,7 +213,7 @@ class DeviceFormat(object):
     def dict(self):
         d = {"type": self.type, "name": self.name, "device": self.device,
              "uuid": self.uuid, "exists": self.exists,
-             "options": self.options, "supported": self.supported,
+             "options": self.options, "supported": self.supported(),
              "resizable": self.resizable}
         return d
 
@@ -421,10 +421,10 @@ class DeviceFormat(object):
         """ Can we create formats of this type? """
         return self._formattable
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         """ Is this format a supported type? """
-        return self._supported
+        return cls._supported
 
     @property
     def packages(self):
diff --git a/blivet/formats/biosboot.py b/blivet/formats/biosboot.py
index c3aef8d..e5aacbf 100644
--- a/blivet/formats/biosboot.py
+++ b/blivet/formats/biosboot.py
@@ -52,8 +52,8 @@ class BIOSBoot(DeviceFormat):
     def status(self):
         return False
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         return isinstance(platform.platform, platform.X86)
 
 register_device_format(BIOSBoot)
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 5d698cd..39f4b7a 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -118,7 +118,7 @@ class FS(DeviceFormat):
 
         self._targetSize = self._size
 
-        if self.supported:
+        if self.supported():
             self.loadModule()
 
     def __repr__(self):
@@ -738,10 +738,10 @@ class FS(DeviceFormat):
 
         return True
 
-    @property
-    def supported(self):
-        log_method_call(self, supported=self._supported)
-        return self._supported and self.utilsAvailable()
+    @classmethod
+    def supported(cls):
+        log_method_call(cls, supported=cls._supported)
+        return cls._supported and cls.utilsAvailable()
 
     @property
     def mountable(self):
@@ -1043,10 +1043,10 @@ class EFIFS(FATFS):
     _name = "EFI System Partition"
     _minSize = 50
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         return (isinstance(platform.platform, platform.EFI) and
-                self.utilsAvailable())
+                cls.utilsAvailable())
 
 register_device_format(EFIFS)
 
@@ -1115,12 +1115,12 @@ class GFS2(FS):
     # partition table type correctly for btrfs partitions
     # partedSystem = fileSystemType["gfs2"]
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         """ Is this filesystem a supported type? """
-        supported = self._supported
+        supported = cls._supported
         if flags.gfs2:
-            supported = self.utilsAvailable()
+            supported = cls.utilsAvailable()
 
         return supported
 
@@ -1146,12 +1146,12 @@ class JFS(FS):
     _existingSizeFields = ["Aggregate block size:", "Aggregate size:"]
     partedSystem = fileSystemType["jfs"]
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         """ Is this filesystem a supported type? """
-        supported = self._supported
+        supported = cls._supported
         if flags.jfs:
-            supported = self.utilsAvailable()
+            supported = cls.utilsAvailable()
 
         return supported
 
@@ -1179,12 +1179,12 @@ class ReiserFS(FS):
     _existingSizeFields = ["Count of blocks on the device:", "Blocksize:"]
     partedSystem = fileSystemType["reiserfs"]
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         """ Is this filesystem a supported type? """
-        supported = self._supported
+        supported = cls._supported
         if flags.reiserfs:
-            supported = self.utilsAvailable()
+            supported = cls.utilsAvailable()
 
         return supported
 
@@ -1257,10 +1257,10 @@ class AppleBootstrapFS(HFS):
     _minSize = 800.00 / 1024.00
     _maxSize = 1
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         return (isinstance(platform.platform, platform.NewWorldPPC)
-                and self.utilsAvailable())
+                and cls.utilsAvailable())
 
 register_device_format(AppleBootstrapFS)
 
diff --git a/blivet/formats/prepboot.py b/blivet/formats/prepboot.py
index c7ed111..eb2246e 100644
--- a/blivet/formats/prepboot.py
+++ b/blivet/formats/prepboot.py
@@ -79,8 +79,8 @@ class PPCPRePBoot(DeviceFormat):
     def status(self):
         return False
 
-    @property
-    def supported(self):
+    @classmethod
+    def supported(cls):
         return isinstance(platform.platform, platform.IPSeriesPPC)
 
 register_device_format(PPCPRePBoot)
-- 
1.8.3.1



More information about the anaconda-patches mailing list