[blivet:master 6/9] Get rid of a redefined builtin while simplifying method.

Vratislav Podzimek vpodzime at redhat.com
Thu Apr 24 05:48:08 UTC 2014


On Wed, 2014-04-23 at 17:49 -0400, mulhern wrote:
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
>  blivet/devices.py | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/blivet/devices.py b/blivet/devices.py
> index 9d04bb7..7db528d 100644
> --- a/blivet/devices.py
> +++ b/blivet/devices.py
> @@ -1931,13 +1931,9 @@ class DMDevice(StorageDevice):
>  
>      @property
>      def status(self):
> -        _status = False
> -        for map in block.dm.maps():
> -            if map.name == self.mapName:
> -                _status = map.live_table and not map.suspended
> -                break
> -
> -        return _status
> +        match = next((m for m in block.dm.maps() if m.name == self.mapName),
> +           None)
> +        return match.live_table and not match.suspended if match else False
Much nicer than the previous version! Just please add parentheses around
the part before 'if' that should make the line better readable.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list