diff options
author | nfnty <git@nfnty.se> | 2017-01-21 22:51:56 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-21 22:55:46 +0100 |
commit | 4fc54db1bcb243504cdc41cee3885342b94cb13a (patch) | |
tree | 5cddf5caef27797e921a180d3aeaf2ce880f08bf | |
parent | 9f5eeff72146d3c5178d66b4879af7a6abfc22f1 (diff) | |
download | ranger-4fc54db1bcb243504cdc41cee3885342b94cb13a.tar.gz |
Python 3 division: Remove explicit float conversions
-rw-r--r-- | ranger/core/loader.py | 6 | ||||
-rw-r--r-- | ranger/ext/direction.py | 2 | ||||
-rw-r--r-- | ranger/ext/human_readable.py | 20 | ||||
-rw-r--r-- | ranger/ext/img_display.py | 8 | ||||
-rw-r--r-- | ranger/gui/widgets/statusbar.py | 4 | ||||
-rw-r--r-- | ranger/gui/widgets/taskview.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/view_miller.py | 4 | ||||
-rw-r--r-- | ranger/gui/widgets/view_multipane.py | 2 |
8 files changed, 24 insertions, 24 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 32c4e2b6..022dfe6b 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -105,7 +105,7 @@ class CopyLoader(Loadable, FileManagerAware): # pylint: disable=too-many-instan n = 0 for n in shutil_g.move(src=fobj.path, dst=self.original_path, overwrite=self.overwrite): - self.percent = float(done + n) / size * 100. + self.percent = ((done + n) / size) * 100. yield done += n else: @@ -122,14 +122,14 @@ class CopyLoader(Loadable, FileManagerAware): # pylint: disable=too-many-instan symlinks=True, overwrite=self.overwrite, ): - self.percent = float(done + n) / size * 100. + self.percent = ((done + n) / size) * 100. yield done += n else: n = 0 for n in shutil_g.copy2(fobj.path, self.original_path, symlinks=True, overwrite=self.overwrite): - self.percent = float(done + n) / size * 100. + self.percent = ((done + n) / size) * 100. yield done += n cwd = self.fm.get_directory(self.original_path) diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 12d82eb0..ecde944a 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -133,7 +133,7 @@ class Direction(dict): if self.pages(): pos *= pagesize elif self.percentage(): - pos *= maximum / 100.0 + pos *= maximum / 100 if self.absolute(): if pos < minimum: pos += maximum diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index ace380dc..df74eabf 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -23,25 +23,25 @@ def human_readable(byte, separator=' '): # pylint: disable=too-many-return-stat if byte < 2**10: return '%d%sB' % (byte, separator) if byte < 2**10 * 999: - return '%.3g%sK' % (byte / 2**10.0, separator) + return '%.3g%sK' % ((byte / 2**10), separator) if byte < 2**20: - return '%.4g%sK' % (byte / 2**10.0, separator) + return '%.4g%sK' % ((byte / 2**10), separator) if byte < 2**20 * 999: - return '%.3g%sM' % (byte / 2**20.0, separator) + return '%.3g%sM' % ((byte / 2**20), separator) if byte < 2**30: - return '%.4g%sM' % (byte / 2**20.0, separator) + return '%.4g%sM' % ((byte / 2**20), separator) if byte < 2**30 * 999: - return '%.3g%sG' % (byte / 2**30.0, separator) + return '%.3g%sG' % ((byte / 2**30), separator) if byte < 2**40: - return '%.4g%sG' % (byte / 2**30.0, separator) + return '%.4g%sG' % ((byte / 2**30), separator) if byte < 2**40 * 999: - return '%.3g%sT' % (byte / 2**40.0, separator) + return '%.3g%sT' % ((byte / 2**40), separator) if byte < 2**50: - return '%.4g%sT' % (byte / 2**40.0, separator) + return '%.4g%sT' % ((byte / 2**40), separator) if byte < 2**50 * 999: - return '%.3g%sP' % (byte / 2**50.0, separator) + return '%.3g%sP' % ((byte / 2**50), separator) if byte < 2**60: - return '%.4g%sP' % (byte / 2**50.0, separator) + return '%.4g%sP' % ((byte / 2**50), separator) return '>9000' diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 2893e391..1b20cc7b 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -238,18 +238,18 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware): max_height = self._minimum_font_height * max_rows if height > max_height: if width > max_width: - width_scale = max_width / float(width) - height_scale = max_height / float(height) + width_scale = max_width / width + height_scale = max_height / height min_scale = min(width_scale, height_scale) max_scale = max(width_scale, height_scale) if width * max_scale <= max_width and height * max_scale <= max_height: return width * max_scale return width * min_scale - scale = max_height / float(height) + scale = max_height / height return width * scale elif width > max_width: - scale = max_width / float(width) + scale = max_width / width return width * scale return width diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 47a9ca9f..c9133415 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -295,7 +295,7 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes elif pos >= max_pos: right.add('Bot', base, 'bot') else: - right.add('{0:0.0%}'.format(float(pos) / max_pos), + right.add('{0:0.0%}'.format((pos / max_pos)), base, 'percentage') else: right.add('0/0 All', base, 'all') @@ -314,7 +314,7 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes states.append(item.percent) if states: state = sum(states) / len(states) - barwidth = state / 100.0 * self.wid + barwidth = (state / 100) * self.wid self.color_at(0, 0, int(barwidth), ("in_statusbar", "loaded")) self.color_reset() diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index bedd9e4e..2c0cafb0 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -55,7 +55,7 @@ class TaskView(Widget, Accumulator): descr = obj.get_description() if obj.progressbar_supported and obj.percent >= 0 and obj.percent <= 100: self.addstr(y, 0, "%3.2f%% - %s" % (obj.percent, descr), self.wid) - wid = int(self.wid / 100.0 * obj.percent) + wid = int((self.wid / 100) * obj.percent) self.color_at(y, 0, self.wid, tuple(clr)) self.color_at(y, 0, wid, tuple(clr), 'loaded') else: diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index da6b529f..569b93fa 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -56,8 +56,8 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta self.remove_child(column) self.columns = [] - ratio_sum = float(sum(ratios)) - self.ratios = tuple(x / ratio_sum for x in ratios) + ratios_sum = sum(ratios) + self.ratios = tuple((x / ratios_sum) for x in ratios) last = 0.1 if self.settings.padding_right else 0 if len(self.ratios) >= 2: diff --git a/ranger/gui/widgets/view_multipane.py b/ranger/gui/widgets/view_multipane.py index 6b3d9232..9661d31e 100644 --- a/ranger/gui/widgets/view_multipane.py +++ b/ranger/gui/widgets/view_multipane.py @@ -45,7 +45,7 @@ class ViewMultipane(ViewBase): # pylint: disable=too-many-ancestors def resize(self, y, x, hei=None, wid=None): ViewBase.resize(self, y, x, hei, wid) - column_width = int((float(wid) - len(self.columns) + 1) / len(self.columns)) + column_width = int((wid - len(self.columns) + 1) / len(self.columns)) left = 0 top = 0 for column in self.columns: |