[PATCH 1/3] Don't try to use math.ceil on blivet.size.Size instances. (#1164191)

Anne Mulhern amulhern at redhat.com
Wed Jan 7 12:57:45 UTC 2015





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Tuesday, January 6, 2015 8:04:36 PM
> Subject: Re: [PATCH 1/3] Don't try to use math.ceil on blivet.size.Size	instances. (#1164191)
> 
> On 01/06/2015 03:05 PM, Anne Mulhern wrote:
> >
> >
> >
> >
> > ----- Original Message -----
> >> From: "David Lehman" <dlehman at redhat.com>
> >> To: anaconda-patches at lists.fedorahosted.org
> >> Sent: Tuesday, January 6, 2015 3:20:13 PM
> >> Subject: [PATCH 1/3] Don't try to use math.ceil on blivet.size.Size
> >> instances.	(#1164191)
> >>
> >> This is a remnant of the days before blivet used blivet.size.Size for
> >> all size quantities.
> >> ---
> >>   pyanaconda/ui/gui/spokes/lib/resize.py | 19 +++++++++----------
> >>   1 file changed, 9 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py
> >> b/pyanaconda/ui/gui/spokes/lib/resize.py
> >> index 2edba6b..26e7125 100644
> >> --- a/pyanaconda/ui/gui/spokes/lib/resize.py
> >> +++ b/pyanaconda/ui/gui/spokes/lib/resize.py
> >> @@ -21,7 +21,6 @@
> >>
> >>   from __future__ import division
> >>   from collections import namedtuple
> >> -from math import ceil
> >>
> >>   from gi.repository import Gdk, Gtk
> >>
> >> @@ -241,27 +240,27 @@ class ResizeDialog(GUIObject):
> >>              will not have a slider displayed, so they do not need to be
> >>              worried
> >>              with here.
> >>           """
> >> -        self._resizeSlider.set_range(int(ceil(device.minSize)),
> >> int(device.size))
> >> -        self._resizeSlider.set_value(value)
> >> +        self._resizeSlider.set_range(int(device.minSize),
> >> int(device.size))
> >> +        self._resizeSlider.set_value(int(value))
> >>
> >>           # The slider needs to be keyboard-accessible.  We'll make small
> >>           movements change in
> >>           # 1% increments, and large movements in 5% increments.
> >>           distance = device.size - device.minSize
> >
> > More proper to convert distance to an int and make divisors floats.
> 
> Since the ints represent a byte count I think I'll make distance an int
> and leave the divisors ints, dropping the surrounding cast entirely.

Sounds good, unless there might arise some problem due to very small distance.

> 
> >
> >> -        onePercent = Size(distance / 100)
> >> -        fivePercent = Size(distance / 20)
> >> -        twentyPercent = Size(distance / 5)
> >> +        onePercent = int(distance / 100)
> >> +        fivePercent = int(distance / 20)
> >> +        twentyPercent = int(distance / 5)
> >>

<-- SNIP -->

> >>
> >> _______________________________________________
> >> anaconda-patches mailing list
> >> anaconda-patches at lists.fedorahosted.org
> >> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> >>
> >
> > Other than one inline comment, ack.
> >
> > - mulhern
> > _______________________________________________
> > anaconda-patches mailing list
> > anaconda-patches at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> >
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 


More information about the anaconda-patches mailing list