summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--examples/plugin_file_filter.py6
-rw-r--r--examples/plugin_linemode.py6
-rw-r--r--ranger/api/commands.py6
-rwxr-xr-xranger/config/commands.py10
-rw-r--r--ranger/container/directory.py26
-rw-r--r--ranger/container/fsobject.py2
-rw-r--r--ranger/container/settings.py2
-rw-r--r--ranger/core/actions.py11
-rw-r--r--ranger/core/linemode.py48
-rw-r--r--ranger/ext/img_display.py6
-rw-r--r--ranger/ext/signals.py2
-rw-r--r--ranger/gui/widgets/browsercolumn.py2
-rw-r--r--ranger/gui/widgets/console.py2
13 files changed, 66 insertions, 63 deletions
diff --git a/examples/plugin_file_filter.py b/examples/plugin_file_filter.py
index 486e59d9..aece68f8 100644
--- a/examples/plugin_file_filter.py
+++ b/examples/plugin_file_filter.py
@@ -13,11 +13,11 @@ HIDE_FILES = ("/boot", "/sbin", "/proc", "/sys")
 
 
 # Define a new one
-def custom_accept_file(file, filters):
-    if not file.fm.settings.show_hidden and file.path in HIDE_FILES:
+def custom_accept_file(fobj, filters):
+    if not fobj.fm.settings.show_hidden and fobj.path in HIDE_FILES:
         return False
     else:
-        return ACCEPT_FILE_OLD(file, filters)
+        return ACCEPT_FILE_OLD(fobj, filters)
 
 
 # Overwrite the old function
diff --git a/examples/plugin_linemode.py b/examples/plugin_linemode.py
index 6f16743d..febde8f1 100644
--- a/examples/plugin_linemode.py
+++ b/examples/plugin_linemode.py
@@ -15,8 +15,8 @@ from ranger.core.linemode import LinemodeBase
 class MyLinemode(LinemodeBase):
     name = "rot13"
 
-    def filetitle(self, file, metadata):
-        return codecs.encode(file.relative_path, "rot_13")
+    def filetitle(self, fobj, metadata):
+        return codecs.encode(fobj.relative_path, "rot_13")
 
-    def infostring(self, file, metadata):
+    def infostring(self, fobj, metadata):
         raise NotImplementedError
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index 76fe588a..1d833dda 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -441,8 +441,10 @@ class AliasCommand(Command):
 
     def tab(self, tabnum):
         cmd = self._make_cmd()
-        args = inspect.signature(cmd.tab).parameters if self.fm.py3 else \
-            inspect.getargspec(cmd.tab).args  # pylint: disable=deprecated-method
+        if self.fm.py3:
+            args = inspect.signature(cmd.tab).parameters  # pylint: disable=no-member
+        else:
+            args = inspect.getargspec(cmd.tab).args  # pylint: disable=deprecated-method
         return cmd.tab(tabnum) if 'tabnum' in args else cmd.tab()
 
     def cancel(self):
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index a3a44278..98af27e3 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -142,7 +142,7 @@ class cd(Command):
         else:
             self.fm.cd(destination)
 
-    def tab(self, tabnum):
+    def tab(self, tabnum):  # pylint: disable=too-many-locals
         from os.path import dirname, basename, expanduser, join
 
         cwd = self.fm.thisdir.path
@@ -836,9 +836,9 @@ class chmod(Command):
             self.fm.notify("Need an octal number between 0 and 777!", bad=True)
             return
 
-        for file in self.fm.thistab.get_selection():
+        for fobj in self.fm.thistab.get_selection():
             try:
-                os.chmod(file.path, mode)
+                os.chmod(fobj.path, mode)
             except Exception as ex:
                 self.fm.notify(ex)
 
@@ -1466,8 +1466,8 @@ class meta(prompt_metadata):
         if key in metadata and metadata[key]:
             return [" ".join([self.arg(0), self.arg(1), metadata[key]])]
         else:
-            return [self.arg(0) + " " + key for key in sorted(metadata)
-                    if key.startswith(self.arg(1))]
+            return [self.arg(0) + " " + k for k in sorted(metadata)
+                    if k.startswith(self.arg(1))]
 
 
 class linemode(default_linemode):
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 72a9cd33..fbae9a93 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -55,17 +55,17 @@ def sort_unicode_wrapper_list(old_sort_func):
     return sort_unicode
 
 
-def accept_file(file, filters):
+def accept_file(fobj, filters):
     """
     Returns True if file shall be shown, otherwise False.
     Parameters:
-        file - an instance of FileSystemObject
-        filters - an array of lambdas, each expects a file and
-                  returns True if file shall be shown,
+        fobj - an instance of FileSystemObject
+        filters - an array of lambdas, each expects a fobj and
+                  returns True if fobj shall be shown,
                   otherwise False.
     """
     for filt in filters:
-        if filt and not filt(file):
+        if filt and not filt(fobj):
             return False
     return True
 
@@ -233,15 +233,15 @@ class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public
         if not self.settings.show_hidden and self.settings.hidden_filter:
             hidden_filter = re.compile(self.settings.hidden_filter)
             hidden_filter_search = hidden_filter.search
-            filters.append(lambda file: not hidden_filter_search(file.basename))
+            filters.append(lambda fobj: not hidden_filter_search(fobj.basename))
         if self.filter:
             filter_search = self.filter.search
-            filters.append(lambda file: filter_search(file.basename))
+            filters.append(lambda fobj: filter_search(fobj.basename))
         if self.inode_type_filter:
             filters.append(self.inode_type_filter)
         if self.temporary_filter:
             temporary_filter_search = self.temporary_filter.search
-            filters.append(lambda file: temporary_filter_search(file.basename))
+            filters.append(lambda fobj: temporary_filter_search(fobj.basename))
 
         self.files = [f for f in self.files_all if accept_file(f, filters)]
 
@@ -488,12 +488,12 @@ class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public
         cum = 0
         realpath = os.path.realpath
         for dirpath, _, filenames in os.walk(self.path, onerror=lambda _: None):
-            for file in filenames:
+            for fname in filenames:
                 try:
                     if dirpath == self.path:
-                        stat = os_stat(realpath(dirpath + "/" + file))
+                        stat = os_stat(realpath(dirpath + "/" + fname))
                     else:
-                        stat = os_stat(dirpath + "/" + file)
+                        stat = os_stat(dirpath + "/" + fname)
                     cum += stat.st_size
                 except Exception:
                     pass
@@ -660,8 +660,8 @@ class Directory(  # pylint: disable=too-many-instance-attributes,too-many-public
         return self.files is None or len(self.files) == 0
 
     def _set_linemode_of_children(self, mode):
-        for file in self.files:
-            file._set_linemode(mode)  # pylint: disable=protected-access
+        for fobj in self.files:
+            fobj._set_linemode(mode)  # pylint: disable=protected-access
 
     def __nonzero__(self):
         """Always True"""
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 619f5df5..f4d84bc1 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -17,7 +17,7 @@ from ranger.ext.lazy_property import lazy_property
 from ranger.ext.human_readable import human_readable
 
 if hasattr(str, 'maketrans'):
-    maketrans = str.maketrans  # pylint: disable=invalid-name
+    maketrans = str.maketrans  # pylint: disable=invalid-name,no-member
 else:
     from string import maketrans  # pylint: disable=no-name-in-module
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 5424bffb..b135612a 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -261,7 +261,7 @@ class Settings(SignalDispatcher, FileManagerAware):
         self._raw_set(signal.setting, signal.value, signal.path, signal.tags)
 
 
-class LocalSettings():  # pylint: disable=too-few-public-methods
+class LocalSettings(object):  # pylint: disable=too-few-public-methods
 
     def __init__(self, path, parent):
         self.__dict__['_parent'] = parent
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 4f3338d2..7473fd78 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -591,7 +591,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
     def execute_command(self, cmd, **kw):
         return self.run(cmd, **kw)
 
-    def edit_file(self, file=None):
+    def edit_file(self, file=None):  # pylint: disable=redefined-builtin
         """Calls execute_file with the current file and label='editor'"""
         if file is None:
             file = self.thisfile
@@ -929,9 +929,9 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
                                 sha1(path.encode('utf-8', 'backslashreplace'))
                                 .hexdigest()) + '.jpg'
 
-    def get_preview(self, file, width, height):  # pylint: disable=too-many-return-statements
+    def get_preview(self, fobj, width, height):  # pylint: disable=too-many-return-statements
         pager = self.ui.get_pager()
-        path = file.realpath
+        path = fobj.realpath
 
         if not path or not os.path.exists(path):
             return None
@@ -1143,7 +1143,8 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             file_selection = None
             if create_directory:
                 try:
-                    os.makedirs(path, exist_ok=True)
+                    if not os.path.isdir(path):
+                        os.makedirs(path)
                 except OSError as err:
                     self.fm.notify(err, bad=True)
                     return
@@ -1372,7 +1373,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             for tag in self.fm.tags.tags:
                 if str(tag).startswith(path):
                     self.fm.tags.remove(tag)
-        self.copy_buffer = set(filter(lambda fobj: fobj.path not in files, self.copy_buffer))
+        self.copy_buffer = set(fobj for fobj in self.copy_buffer if fobj.path not in files)
         for path in files:
             if isdir(path) and not os.path.islink(path):
                 try:
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index d9d91350..b79351c4 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -33,11 +33,11 @@ class LinemodeBase(object):
     name = abstractproperty()
 
     @abstractmethod
-    def filetitle(self, file, metadata):
+    def filetitle(self, fobj, metadata):
         """The left-aligned part of the line."""
         raise NotImplementedError
 
-    def infostring(self, file, metadata):
+    def infostring(self, fobj, metadata):
         """The right-aligned part of the line.
 
         If `NotImplementedError' is raised (e.g. this method is just
@@ -55,8 +55,8 @@ class LinemodeBase(object):
 class DefaultLinemode(LinemodeBase):  # pylint: disable=abstract-method
     name = "filename"
 
-    def filetitle(self, file, metadata):
-        return file.relative_path
+    def filetitle(self, fobj, metadata):
+        return fobj.relative_path
 
 
 class TitleLinemode(LinemodeBase):
@@ -64,14 +64,14 @@ class TitleLinemode(LinemodeBase):
     uses_metadata = True
     required_metadata = ["title"]
 
-    def filetitle(self, file, metadata):
+    def filetitle(self, fobj, metadata):
         name = metadata.title
         if metadata.year:
             return "%s - %s" % (metadata.year, name)
         else:
             return name
 
-    def infostring(self, file, metadata):
+    def infostring(self, fobj, metadata):
         if metadata.authors:
             authorstring = metadata.authors
             if ',' in authorstring:
@@ -83,25 +83,25 @@ class TitleLinemode(LinemodeBase):
 class PermissionsLinemode(LinemodeBase):
     name = "permissions"
 
-    def filetitle(self, file, metadata):
-        return "%s %s %s %s" % (file.get_permission_string(),
-                                file.user, file.group, file.relative_path)
+    def filetitle(self, fobj, metadata):
+        return "%s %s %s %s" % (fobj.get_permission_string(),
+                                fobj.user, fobj.group, fobj.relative_path)
 
-    def infostring(self, file, metadata):
+    def infostring(self, fobj, metadata):
         return ""
 
 
 class FileInfoLinemode(LinemodeBase):
     name = "fileinfo"
 
-    def filetitle(self, file, metadata):
-        return file.relative_path
+    def filetitle(self, fobj, metadata):
+        return fobj.relative_path
 
-    def infostring(self, file, metadata):
-        if not file.is_directory:
+    def infostring(self, fobj, metadata):
+        if not fobj.is_directory:
             from subprocess import CalledProcessError
             try:
-                fileinfo = spawn.check_output(["file", "-bL", file.path]).strip()
+                fileinfo = spawn.check_output(["file", "-bL", fobj.path]).strip()
             except CalledProcessError:
                 return "unknown"
             if sys.version_info[0] >= 3:
@@ -114,19 +114,19 @@ class FileInfoLinemode(LinemodeBase):
 class MtimeLinemode(LinemodeBase):
     name = "mtime"
 
-    def filetitle(self, file, metadata):
-        return file.relative_path
+    def filetitle(self, fobj, metadata):
+        return fobj.relative_path
 
-    def infostring(self, file, metadata):
-        return datetime.fromtimestamp(file.stat.st_mtime).strftime("%Y-%m-%d %H:%M")
+    def infostring(self, fobj, metadata):
+        return datetime.fromtimestamp(fobj.stat.st_mtime).strftime("%Y-%m-%d %H:%M")
 
 
 class SizeMtimeLinemode(LinemodeBase):
     name = "sizemtime"
 
-    def filetitle(self, file, metadata):
-        return file.relative_path
+    def filetitle(self, fobj, metadata):
+        return fobj.relative_path
 
-    def infostring(self, file, metadata):
-        return "%s %s" % (human_readable(file.size),
-                          datetime.fromtimestamp(file.stat.st_mtime).strftime("%Y-%m-%d %H:%M"))
+    def infostring(self, fobj, metadata):
+        return "%s %s" % (human_readable(fobj.size),
+                          datetime.fromtimestamp(fobj.stat.st_mtime).strftime("%Y-%m-%d %H:%M"))
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index c40c084a..4a12446e 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -253,13 +253,13 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware):
     @staticmethod
     def _encode_image_content(path):
         """Read and encode the contents of path"""
-        file = open(path, 'rb')
+        fobj = open(path, 'rb')
         try:
-            return base64.b64encode(file.read())
+            return base64.b64encode(fobj.read())
         except Exception:
             return ""
         finally:
-            file.close()
+            fobj.close()
 
     @staticmethod
     def _get_image_dimensions(path):
diff --git a/ranger/ext/signals.py b/ranger/ext/signals.py
index 3800a6ea..d7242a79 100644
--- a/ranger/ext/signals.py
+++ b/ranger/ext/signals.py
@@ -82,7 +82,7 @@ class Signal(dict):
         self.stopped = True
 
 
-class SignalHandler:  # pylint: disable=too-few-public-methods
+class SignalHandler(object):  # pylint: disable=too-few-public-methods
     """Signal Handlers contain information about a signal binding.
 
     They are returned by signal_bind() and have to be passed to signal_unbind()
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 28216dd5..fa6c89fe 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -391,7 +391,7 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
 
     @staticmethod
     def _total_len(predisplay):
-        return sum([len(WideString(s)) for s, L in predisplay])
+        return sum([len(WideString(s)) for s, _ in predisplay])
 
     def _draw_text_display(self, text, space):
         wtext = WideString(text)
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index ecd98d9b..19090620 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -304,7 +304,7 @@ class Console(Widget):  # pylint: disable=too-many-instance-attributes,too-many-
         ...     # it works fine in ranger, even with unicode input...
         ...     line = "ohai world,  this is dog"
         ... else:
-        ...     line = "\u30AA\u30CF\u30E8\u30A6 world,  this is dog"
+        ...     line = "\\u30AA\\u30CF\\u30E8\\u30A6 world,  this is dog"
         >>> Console.move_by_word(line, 0, -1)
         0
         >>> Console.move_by_word(line, 0, 1)