diff options
-rw-r--r-- | ranger/fsobject/directory.py | 3 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 18 |
2 files changed, 7 insertions, 14 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 91d087af..1ab6a3c7 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -188,8 +188,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): files.append(item) yield - self.disk_usage = sum(isinstance(f, File) and f.size or 0 \ - for f in files) + self.disk_usage = sum(f.size for f in files if f.is_file) self.scroll_offset = 0 self.filenames = filenames diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 5890c209..5e16498e 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -92,13 +92,10 @@ class BrowserColumn(Pager, Widget): return True def has_preview(self): - from ranger.fsobject.file import File - from ranger.fsobject.directory import Directory - if self.target is None: return False - if isinstance(self.target, File): + if self.target.is_file: if not self._preview_this_file(self.target): return False @@ -111,19 +108,17 @@ class BrowserColumn(Pager, Widget): def draw(self): """Call either _draw_file() or _draw_directory()""" from ranger import log - from ranger.fsobject.file import File - from ranger.fsobject.directory import Directory if self.target != self.old_dir: self.need_redraw = True self.old_dir = self.target - if isinstance(self.target, Directory) \ + if self.target.is_directory \ and self.target.pointed_obj != self.old_cf: self.need_redraw = True self.old_cf = self.target.pointed_obj - if type(self.target) == Directory: + if self.target.is_directory: if self.target.load_content_if_outdated(): self.need_redraw = True elif self.target.sort_if_outdated(): @@ -135,10 +130,10 @@ class BrowserColumn(Pager, Widget): self.win.erase() if self.target is None: pass - elif type(self.target) == File: + elif self.target.is_file: Pager.open(self) self._draw_file() - elif type(self.target) == Directory: + elif self.target.is_directory: self._draw_directory() Widget.draw(self) self.need_redraw = False @@ -170,7 +165,6 @@ class BrowserColumn(Pager, Widget): def _draw_directory(self): """Draw the contents of a directory""" - from ranger.fsobject.directory import Directory import stat base_color = ['in_browser'] @@ -228,7 +222,7 @@ class BrowserColumn(Pager, Widget): if self.main_column: text = self.tagged_marker + text - if isinstance(drawed, Directory): + if drawed.is_directory: this_color.append('directory') else: this_color.append('file') |