[blivet:rhel7-master 2/6] Substitute simple value for single element array.

mulhern amulhern at redhat.com
Fri Dec 12 15:59:43 UTC 2014


When you encounter an array, you kind of assume that there is some situation
under which it could contain other than exactly one value. If there is
no such situation, as is the case here, might as well not make it an
array. So, use format_designator instead of args.

Also, use format_designator in the error message. The error message is
about failure to look up a proper format, and it seems more reasonable
to include the format type with which the format was actually looked up,
which differs slightly from format_type.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devicetree.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 719fcf8..6238a0e 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1759,7 +1759,7 @@ class DeviceTree(object):
             return
 
         # set up the common arguments for the format constructor
-        args = [format_type]
+        format_designator = format_type
         kwargs = {"uuid": uuid,
                   "label": label,
                   "device": device.path,
@@ -1804,19 +1804,19 @@ class DeviceTree(object):
             if isinstance(device, PartitionDevice) and device.bootable:
                 efi = formats.getFormat("efi")
                 if efi.minSize <= device.size <= efi.maxSize:
-                    args[0] = "efi"
+                    format_designator = "efi"
         elif format_type == "hfsplus":
             if isinstance(device, PartitionDevice):
                 macefi = formats.getFormat("macefi")
                 if macefi.minSize <= device.size <= macefi.maxSize and \
                    device.partedPartition.name == macefi.name:
-                    args[0] = "macefi"
+                    format_designator = "macefi"
         elif format_type == "hfs":
             # apple bootstrap magic
             if isinstance(device, PartitionDevice) and device.bootable:
                 apple = formats.getFormat("appleboot")
                 if apple.minSize <= device.size <= apple.maxSize:
-                    args[0] = "appleboot"
+                    format_designator = "appleboot"
         elif format_type == "btrfs":
             # the format's uuid attr will contain the UUID_SUB, while the
             # overarching volume UUID will be stored as volUUID
@@ -1824,13 +1824,13 @@ class DeviceTree(object):
             kwargs["volUUID"] = uuid
 
         try:
-            log.info("type detected on '%s' is '%s'", name, format_type)
-            device.format = formats.getFormat(*args, **kwargs)
+            log.info("type detected on '%s' is '%s'", name, format_designator)
+            device.format = formats.getFormat(format_designator, **kwargs)
             if device.format.type:
                 log.info("got format: %s", device.format)
         except FSError:
             log.warning("type '%s' on '%s' invalid, assuming no format",
-                      format_type, name)
+                      format_designator, name)
             device.format = formats.DeviceFormat()
             return
 
-- 
1.9.3



More information about the anaconda-patches mailing list