[PATCH 3/3] Use namedtuple, where possible, in the resize dialog.

Vratislav Podzimek vpodzime at redhat.com
Wed Jun 5 08:25:55 UTC 2013


On Tue, 2013-06-04 at 13:27 -0400, Chris Lumens wrote:
> ---
>  pyanaconda/ui/gui/spokes/lib/resize.py | 59 ++++++++++++++++++----------------
>  1 file changed, 32 insertions(+), 27 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
> index 1ec737a..a44db64 100644
> --- a/pyanaconda/ui/gui/spokes/lib/resize.py
> +++ b/pyanaconda/ui/gui/spokes/lib/resize.py
> @@ -20,6 +20,7 @@
>  #
>  
>  from __future__ import division
> +from collections import namedtuple
>  
>  # pylint: disable-msg=E0611
>  from gi.repository import Gdk, Gtk
> @@ -41,6 +42,10 @@ TOOLTIP_COL = 6
>  RESIZE_TARGET_COL = 7
>  NAME_COL = 8
>  
> +PartStoreRow = namedtuple("PartStoreRow", ["id", "desc", "fs", "reclaimable",
> +                                           "action", "editable", "tooltip",
> +                                           "target", "name"])
> +
>  PRESERVE = N_("Preserve")
>  SHRINK = N_("Shrink")
>  DELETE = N_("Delete")
> @@ -239,32 +244,33 @@ class ResizeDialog(GUIObject):
>          self._resizeSlider.add_mark(device.size, Gtk.PositionType.BOTTOM, size_str(device.size))
>  
>      def _update_action_buttons(self, row):
> -        device = self.storage.devicetree.getDeviceByID(row[DEVICE_ID_COL])
> +        obj = PartStoreRow._make(row)
Great idea! You just don't need to use '_make' and just create a new
instance by 'PartStoreRow(row)'. Apart from this and the two comments to
PATCH 1/3 these all look good to me.

-- 
Vratislav Podzimek

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



More information about the anaconda-patches mailing list