[blivet:rhel7/master 7/8] Make empty_device an instance method of DeviceTree (#1043763)
Vratislav Podzimek
vpodzime at redhat.com
Tue Feb 25 09:55:52 UTC 2014
On Mon, 2014-02-24 at 12:42 -0500, mulhern wrote:
> Related: rhbz#1043763
>
> So that it is easily accessible from other instance methods of DeviceTree.
>
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
> blivet/__init__.py | 15 ++-------------
> blivet/devicetree.py | 10 ++++++++++
> 2 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/blivet/__init__.py b/blivet/__init__.py
> index c238b84..d8ce372 100644
> --- a/blivet/__init__.py
> +++ b/blivet/__init__.py
> @@ -217,17 +217,6 @@ def writeEscrowPackets(storage):
>
> log.debug("escrow: writeEscrowPackets done")
>
> -def empty_device(device, devicetree):
> - empty = True
> - if device.partitioned:
> - partitions = devicetree.getChildren(device)
> - empty = all([p.isMagic for p in partitions])
> - else:
> - empty = (device.format.type is None)
> -
> - return empty
> -
> -
> class StorageDiscoveryConfig(object):
> """ Class to encapsulate various detection/initialization parameters. """
> def __init__(self):
> @@ -689,7 +678,7 @@ class Blivet(object):
> if not self.config.initializeDisks or not device.isDisk:
> return False
>
> - if not empty_device(device, self.devicetree):
> + if not self.devicetree.emptyDevice(device):
> return False
>
> if isinstance(device, PartitionDevice):
> @@ -714,7 +703,7 @@ class Blivet(object):
> # if clearPartType is not CLEARPART_TYPE_ALL but we'll still be
> # removing every partition from the disk, return True since we
> # will want to be able to create a new disklabel on this disk
> - if not empty_device(device, self.devicetree):
> + if not self.devicetree.emptyDevice(device):
> return False
>
> # Never clear disks with hidden formats
> diff --git a/blivet/devicetree.py b/blivet/devicetree.py
> index abfe7c0..788a22f 100644
> --- a/blivet/devicetree.py
> +++ b/blivet/devicetree.py
> @@ -2308,6 +2308,16 @@ class DeviceTree(object):
> """ Return a list of a device's children. """
> return [c for c in self._devices if device in c.parents]
>
> + def emptyDevice(self, device):
> + empty = True
> + if device.partitioned:
> + partitions = self.getChildren(device)
> + empty = all([p.isMagic for p in partitions])
You can drop the square brackets on this line.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list