[PATCH 1/3] Don't try to use math.ceil on blivet.size.Size instances. (#1164191)
David Lehman
dlehman at redhat.com
Wed Jan 7 01:04:36 UTC 2015
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.
>
>> - onePercent = Size(distance / 100)
>> - fivePercent = Size(distance / 20)
>> - twentyPercent = Size(distance / 5)
>> + onePercent = int(distance / 100)
>> + fivePercent = int(distance / 20)
>> + twentyPercent = int(distance / 5)
>>
>> adjustment = self.builder.get_object("resizeAdjustment")
>> - adjustment.configure(value, int(ceil(device.minSize)),
>> int(device.size), onePercent, fivePercent, 0)
>> + adjustment.configure(int(value), int(device.minSize),
>> int(device.size), onePercent, fivePercent, 0)
>>
>> # And then the slider needs a couple tick marks for easier
>> navigation.
>> self._resizeSlider.clear_marks()
>> for i in range(1, 5):
>> - self._resizeSlider.add_mark(int(ceil(device.minSize)) +
>> i*twentyPercent, Gtk.PositionType.BOTTOM, None)
>> + self._resizeSlider.add_mark(int(device.minSize) +
>> i*twentyPercent, Gtk.PositionType.BOTTOM, None)
>>
>> # Finally, add tick marks for the ends.
>> - self._resizeSlider.add_mark(device.minSize, Gtk.PositionType.BOTTOM,
>> str(device.minSize))
>> - self._resizeSlider.add_mark(device.size, Gtk.PositionType.BOTTOM,
>> str(device.size))
>> + self._resizeSlider.add_mark(int(device.minSize),
>> Gtk.PositionType.BOTTOM, str(device.minSize))
>> + self._resizeSlider.add_mark(int(device.size),
>> Gtk.PositionType.BOTTOM, str(device.size))
>>
>> def _update_action_buttons(self, row):
>> obj = PartStoreRow(*row)
>> --
>> 1.9.3
>>
>> _______________________________________________
>> 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
>
More information about the anaconda-patches
mailing list