summary refs log tree commit diff stats
path: root/ranger/gui/widgets/browsercolumn.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/gui/widgets/browsercolumn.py')
-rw-r--r--ranger/gui/widgets/browsercolumn.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 829809c0..222457c2 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -3,24 +3,23 @@
 
 """The BrowserColumn widget displays the contents of a directory or file."""
 
-import curses
+from __future__ import (absolute_import, print_function)
+
 import stat
 from time import time
 from os.path import splitext
 
-from . import Widget
-from .pager import Pager
 from ranger.ext.widestring import WideString
-
 from ranger.core import linemode
 
-from ranger.gui.color import *
+from . import Widget
+from .pager import Pager
 
 
-class BrowserColumn(Pager):
+class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
     main_column = False
     display_infostring = False
-    display_vcsstate   = True
+    display_vcsstate = True
     scroll_begin = 0
     target = None
     last_redraw_time = -1
@@ -39,13 +38,13 @@ class BrowserColumn(Pager):
         level <0 => parent directories
         """
         Pager.__init__(self, win)
-        Widget.__init__(self, win)
+        Widget.__init__(self, win)  # pylint: disable=non-parent-init-called
         self.level = level
         self.tab = tab
         self.original_level = level
 
         self.settings.signal_bind('setopt.display_size_in_main_column',
-                self.request_redraw, weak=True)
+                                  self.request_redraw, weak=True)
 
     def request_redraw(self):
         self.need_redraw = True
@@ -182,14 +181,14 @@ class BrowserColumn(Pager):
             Pager.close(self)
             return
 
-        f = self.target.get_preview_source(self.wid, self.hei)
-        if f is None:
+        path = self.target.get_preview_source(self.wid, self.hei)
+        if path is None:
             Pager.close(self)
         else:
             if self.target.is_image_preview():
-                self.set_image(f)
+                self.set_image(path)
             else:
-                self.set_source(f)
+                self.set_source(path)
             Pager.draw(self)
 
     def _format_line_number(self, linum_format, i, selected_i):
@@ -201,7 +200,8 @@ class BrowserColumn(Pager):
 
         return linum_format.format(line_number)
 
-    def _draw_directory(self):
+    def _draw_directory(  # pylint: disable=too-many-locals,too-many-branches,too-many-statements
+            self):
         """Draw the contents of a directory"""
         if self.image:
             self.image = None
@@ -273,7 +273,8 @@ class BrowserColumn(Pager):
 
             # Extract linemode-related information from the drawn object
             metadata = None
-            current_linemode = drawn.linemode_dict[drawn._linemode]
+            current_linemode = \
+                drawn.linemode_dict[drawn._linemode]  # pylint: disable=protected-access
             if current_linemode.uses_metadata:
                 metadata = self.fm.metadata.get_metadata(drawn.path)
                 if not all(getattr(metadata, tag)
@@ -303,7 +304,7 @@ class BrowserColumn(Pager):
             text = current_linemode.filetitle(drawn, metadata)
 
             if drawn.marked and (self.main_column or
-                    self.settings.display_tags_in_all_columns):
+                                 self.settings.display_tags_in_all_columns):
                 text = " " + text
 
             # Computing predisplay data. predisplay contains a list of lists
@@ -366,13 +367,13 @@ class BrowserColumn(Pager):
                 predisplay_left.append([' ' * space, []])
             elif space < 0:
                 raise Exception("Error: there is not enough space to write "
-                        "the text. I have computed spaces wrong.")
+                                "the text. I have computed spaces wrong.")
 
             # Computing display data. Now we compute the display_data list
             # ready to display in curses. It is a list of lists [string, attr]
 
             this_color = base_color + list(drawn.mimetype_tuple) + \
-                    self._draw_directory_color(i, drawn, copied)
+                self._draw_directory_color(i, drawn, copied)
             display_data = []
             drawn.display_data[key] = display_data
 
@@ -387,11 +388,11 @@ class BrowserColumn(Pager):
     def _get_index_of_selected_file(self):
         if self.fm.ui.viewmode == 'multipane' and hasattr(self, 'tab'):
             return self.tab.pointer
-        else:
-            return self.target.pointer
+        return self.target.pointer
 
-    def _total_len(self, predisplay):
-        return sum([len(WideString(s)) for s, L in predisplay])
+    @staticmethod
+    def _total_len(predisplay):
+        return sum([len(WideString(s)) for s, _ in predisplay])
 
     def _draw_text_display(self, text, space):
         wtext = WideString(text)
@@ -479,7 +480,7 @@ class BrowserColumn(Pager):
 
         return this_color
 
-    def _get_scroll_begin(self):
+    def _get_scroll_begin(self):  # pylint: disable=too-many-return-statements
         """Determines scroll_begin (the position of the first displayed file)"""
         offset = self.settings.scroll_offset
         dirsize = len(self.target)
@@ -509,12 +510,10 @@ class BrowserColumn(Pager):
             return original
 
         if projected > upper_limit:
-            return min(dirsize - winsize,
-                    original + (projected - upper_limit))
+            return min(dirsize - winsize, original + (projected - upper_limit))
 
         if projected < upper_limit:
-            return max(0,
-                    original - (lower_limit - projected))
+            return max(0, original - (lower_limit - projected))
 
         return original