summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/api/commands.py14
-rwxr-xr-xranger/config/commands.py32
-rw-r--r--ranger/config/commands_sample.py2
-rw-r--r--ranger/container/directory.py12
-rw-r--r--ranger/container/fsobject.py8
-rw-r--r--ranger/container/settings.py6
-rw-r--r--ranger/core/actions.py20
-rw-r--r--ranger/core/fm.py8
-rw-r--r--ranger/core/loader.py14
-rw-r--r--ranger/core/main.py18
-rw-r--r--ranger/core/runner.py4
-rw-r--r--ranger/core/tab.py2
-rw-r--r--ranger/ext/img_display.py18
-rw-r--r--ranger/ext/keybinding_parser.py2
-rwxr-xr-xranger/ext/rifle.py2
-rw-r--r--ranger/ext/shell_escape.py4
-rw-r--r--ranger/gui/ansi.py2
-rw-r--r--ranger/gui/colorscheme.py2
-rw-r--r--ranger/gui/context.py4
-rw-r--r--ranger/gui/ui.py14
-rw-r--r--ranger/gui/widgets/browsercolumn.py2
-rw-r--r--ranger/gui/widgets/console.py2
-rw-r--r--ranger/gui/widgets/taskview.py2
-rw-r--r--ranger/gui/widgets/view_base.py4
-rw-r--r--ranger/gui/widgets/view_miller.py6
-rwxr-xr-xsetup.py2
26 files changed, 106 insertions, 100 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index df70679c..6a9abe65 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -57,8 +57,8 @@ class CommandContainer(object):
 
     def get_command(self, name, abbrev=True):
         if abbrev:
-            lst = [cls for cmd, cls in self.commands.items() \
-                    if cls.allow_abbrev and cmd.startswith(name) \
+            lst = [cls for cmd, cls in self.commands.items()
+                    if cls.allow_abbrev and cmd.startswith(name)
                     or cmd == name]
             if len(lst) == 0:
                 raise KeyError
@@ -142,7 +142,7 @@ class Command(FileManagerAware):
 
     def start(self, n):
         """Returns everything until (inclusively) arg(n)"""
-        return ' '.join(self.args[:n]) + " " # XXX
+        return ' '.join(self.args[:n]) + " "  # XXX
 
     def shift(self):
         del self.args[0]
@@ -274,7 +274,7 @@ class Command(FileManagerAware):
             # are we in the middle of the filename?
             else:
                 _, dirnames, _ = next(os.walk(abs_dirname))
-                dirnames = [dn for dn in dirnames \
+                dirnames = [dn for dn in dirnames
                         if dn.startswith(rel_basename)]
         except (OSError, StopIteration):
             # os.walk found nothing
@@ -333,7 +333,7 @@ class Command(FileManagerAware):
             else:
                 if directory.content_loaded:
                     # Take the order from the directory object
-                    names = [f.basename for f in directory.files \
+                    names = [f.basename for f in directory.files
                             if f.basename.startswith(rel_basename)]
                     if self.fm.thisfile.basename in names:
                         i = names.index(self.fm.thisfile.basename)
@@ -341,7 +341,7 @@ class Command(FileManagerAware):
                 else:
                     # Fall back to old method with "os.walk"
                     _, dirnames, filenames = next(os.walk(abs_dirname))
-                    names = [name for name in (dirnames + filenames) \
+                    names = [name for name in (dirnames + filenames)
                             if name.startswith(rel_basename)]
                     names.sort()
         except (OSError, StopIteration):
@@ -364,7 +364,7 @@ class Command(FileManagerAware):
 
     def _tab_through_executables(self):
         from ranger.ext.get_executables import get_executables
-        programs = [program for program in get_executables() if \
+        programs = [program for program in get_executables() if
                 program.startswith(self.rest(1))]
         if not programs:
             return
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index cb4fd3a8..1bb688cb 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -166,7 +166,7 @@ class cd(Command):
             # are we in the middle of the filename?
             else:
                 _, dirnames, _ = next(os.walk(abs_dirname))
-                dirnames = [dn for dn in dirnames \
+                dirnames = [dn for dn in dirnames
                         if dn.startswith(rel_basename)]
         except (OSError, StopIteration):
             # os.walk found nothing
@@ -224,7 +224,7 @@ class shell(Command):
         try:
             position_of_last_space = command.rindex(" ")
         except ValueError:
-            return (start + program + ' ' for program \
+            return (start + program + ' ' for program
                     in get_executables() if program.startswith(command))
         if position_of_last_space == len(command) - 1:
             selection = self.fm.thistab.get_selection()
@@ -234,8 +234,8 @@ class shell(Command):
                 return self.line + '%s '
         else:
             before_word, start_of_word = self.line.rsplit(' ', 1)
-            return (before_word + ' ' + file.shell_escaped_basename \
-                    for file in self.fm.thisdir.files or [] \
+            return (before_word + ' ' + file.shell_escaped_basename
+                    for file in self.fm.thisdir.files or []
                     if file.shell_escaped_basename.startswith(start_of_word))
 
 
@@ -243,10 +243,10 @@ class open_with(Command):
     def execute(self):
         app, flags, mode = self._get_app_flags_mode(self.rest(1))
         self.fm.execute_file(
-                files = [f for f in self.fm.thistab.get_selection()],
-                app = app,
-                flags = flags,
-                mode = mode)
+                files=[f for f in self.fm.thistab.get_selection()],
+                app=app,
+                flags=flags,
+                mode=mode)
 
     def tab(self, tabnum):
         return self._tab_through_executables()
@@ -358,12 +358,12 @@ class set_(Command):
         if not name:
             return sorted(self.firstpart + setting for setting in settings)
         if not value and not name_done:
-            return sorted(self.firstpart + setting for setting in settings \
+            return sorted(self.firstpart + setting for setting in settings
                     if setting.startswith(name))
         if not value:
             # Cycle through colorschemes when name, but no value is specified
             if name == "colorscheme":
-                return sorted(self.firstpart + colorscheme for colorscheme \
+                return sorted(self.firstpart + colorscheme for colorscheme
                         in get_all_colorschemes())
             return self.firstpart + str(settings[name])
         if bool in settings.types_of(name):
@@ -373,7 +373,7 @@ class set_(Command):
                 return self.firstpart + 'False'
         # Tab complete colorscheme values if incomplete value is present
         if name == "colorscheme":
-            return sorted(self.firstpart + colorscheme for colorscheme \
+            return sorted(self.firstpart + colorscheme for colorscheme
                     in get_all_colorschemes() if colorscheme.startswith(value))
 
 
@@ -528,7 +528,7 @@ class delete(Command):
 
         def is_directory_with_files(f):
             import os.path
-            return (os.path.isdir(f) and not os.path.islink(f) \
+            return (os.path.isdir(f) and not os.path.islink(f)
                 and len(os.listdir(f)) > 0)
 
         if self.rest(1):
@@ -617,9 +617,9 @@ class load_copy_buffer(Command):
             fname = self.fm.confpath(self.copy_buffer_filename)
             f = open(fname, 'r')
         except:
-            return self.fm.notify("Cannot open %s" % \
+            return self.fm.notify("Cannot open %s" %
                     (fname or self.copy_buffer_filename), bad=True)
-        self.fm.copy_buffer = set(File(g) \
+        self.fm.copy_buffer = set(File(g)
             for g in f.read().split("\n") if exists(g))
         f.close()
         self.fm.ui.redraw_main_column()
@@ -638,7 +638,7 @@ class save_copy_buffer(Command):
             fname = self.fm.confpath(self.copy_buffer_filename)
             f = open(fname, 'w')
         except:
-            return self.fm.notify("Cannot open %s" % \
+            return self.fm.notify("Cannot open %s" %
                     (fname or self.copy_buffer_filename), bad=True)
         f.write("\n".join(f.path for f in self.fm.copy_buffer))
         f.close()
@@ -891,7 +891,7 @@ class bulkrename(Command):
         script_lines = []
         script_lines.append("# This file will be executed when you close the editor.\n")
         script_lines.append("# Please double-check everything, clear the file to abort.\n")
-        script_lines.extend("mv -vi -- %s %s\n" % (esc(old), esc(new)) \
+        script_lines.extend("mv -vi -- %s %s\n" % (esc(old), esc(new))
                 for old, new in zip(filenames, new_filenames) if old != new)
         script_content = "".join(script_lines)
         if py3:
diff --git a/ranger/config/commands_sample.py b/ranger/config/commands_sample.py
index ea74b7d6..1386e84e 100644
--- a/ranger/config/commands_sample.py
+++ b/ranger/config/commands_sample.py
@@ -8,7 +8,7 @@
 from ranger.api.commands import *
 
 # A simple command for demonstration purposes follows.
-#------------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
 
 # You can import any python module as needed.
 import os
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 4ffd9bc2..923821a0 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -174,7 +174,7 @@ class Directory(FileSystemObject, Accumulator, Loadable):
     def mark_item(self, item, val):
         item._mark(val)
         if val:
-            if item in self.files and not item in self.marked_items:
+            if item in self.files and item not in self.marked_items:
                 self.marked_items.append(item)
         else:
             while True:
@@ -224,7 +224,7 @@ class Directory(FileSystemObject, Accumulator, Loadable):
 
     def refilter(self):
         if self.files_all is None:
-            return # propably not loaded yet
+            return  # propably not loaded yet
 
         self.last_update_time = time()
 
@@ -460,13 +460,13 @@ class Directory(FileSystemObject, Accumulator, Loadable):
             elif sort_func in (sort_by_basename, sort_by_basename_icase):
                 sort_func = sort_unicode_wrapper_string(sort_func)
 
-        self.files_all.sort(key = sort_func)
+        self.files_all.sort(key=sort_func)
 
         if self.settings.sort_reverse:
             self.files_all.reverse()
 
         if self.settings.sort_directories_first:
-            self.files_all.sort(key = sort_by_directory)
+            self.files_all.sort(key=sort_by_directory)
 
         self.refilter()
 
@@ -553,10 +553,10 @@ class Directory(FileSystemObject, Accumulator, Loadable):
         length = len(self)
 
         if forward:
-            generator = ((self.pointer + (x + offset)) % length \
+            generator = ((self.pointer + (x + offset)) % length
                     for x in range(length - 1))
         else:
-            generator = ((self.pointer - (x + offset)) % length \
+            generator = ((self.pointer - (x + offset)) % length
                     for x in range(length - 1))
 
         for i in generator:
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 2fd6ad26..b6c0c9ec 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -91,7 +91,7 @@ class FileSystemObject(FileManagerAware, SettingsAware):
             path = abspath(path)
         self.path = path
         self.basename = basename(path)
-        if basename_is_rel_to == None:
+        if basename_is_rel_to is None:
             self.relative_path = self.basename
         else:
             self.relative_path = relpath(path, basename_is_rel_to)
@@ -137,12 +137,12 @@ class FileSystemObject(FileManagerAware, SettingsAware):
 
     @lazy_property
     def basename_natural(self):
-        return [('0', int(s)) if s in _integers else (s, 0) \
+        return [('0', int(s)) if s in _integers else (s, 0)
                 for s in _extract_number_re.split(self.relative_path)]
 
     @lazy_property
     def basename_natural_lower(self):
-        return [('0', int(s)) if s in _integers else (s, 0) \
+        return [('0', int(s)) if s in _integers else (s, 0)
                 for s in _extract_number_re.split(self.relative_path_lower)]
 
     @lazy_property
@@ -175,7 +175,7 @@ class FileSystemObject(FileManagerAware, SettingsAware):
         """Used in garbage-collecting.  Override in Directory"""
 
     def look_up_cumulative_size(self):
-        pass # normal files have no cumulative size
+        pass  # normal files have no cumulative size
 
     def set_mimetype(self):
         """assign attributes such as self.video according to the mimetype"""
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index de39c013..18a16b98 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -110,7 +110,7 @@ class Settings(SignalDispatcher, FileManagerAware):
             if not isinstance(value, list) or len(value) < 2:
                 signal.value = [1, 1]
             else:
-                signal.value = [int(i) if str(i).isdigit() else 1 \
+                signal.value = [int(i) if str(i).isdigit() else 1
                         for i in value]
 
         elif name == 'colorscheme':
@@ -219,7 +219,7 @@ class Settings(SignalDispatcher, FileManagerAware):
 
     def _raw_set(self, name, value, path=None, tags=None):
         if path:
-            if not path in self._localsettings:
+            if path not in self._localsettings:
                 try:
                     regex = re.compile(path)
                 except:
@@ -231,7 +231,7 @@ class Settings(SignalDispatcher, FileManagerAware):
 
             # make sure name is in _settings, so __iter__ runs through
             # local settings too.
-            if not name in self._settings:
+            if name not in self._settings:
                 type_ = self.types_of(name)[0]
                 value = DEFAULT_VALUES[type_]
                 self._settings[name] = value
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index bce36622..d7385355 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -121,7 +121,7 @@ class Actions(FileManagerAware, SettingsAware):
         """
         if self.mode == 'normal':
             self._visual_reverse = reverse
-            if narg != None:
+            if narg is not None:
                 self.mark_files(val=not reverse, narg=narg)
             self.change_mode('visual')
         else:
@@ -149,7 +149,7 @@ class Actions(FileManagerAware, SettingsAware):
             if ranger.arg.debug:
                 raise
             bad = True
-        elif bad == True and ranger.arg.debug:
+        elif bad is True and ranger.arg.debug:
             raise Exception(str(text))
         text = str(text)
         self.log.appendleft(text)
@@ -205,7 +205,7 @@ class Actions(FileManagerAware, SettingsAware):
             return
         cmd = cmd_class(string)
         if cmd.resolve_macros and _MacroTemplate.delimiter in string:
-            macros = dict(('any%d' % i, key_to_string(char)) \
+            macros = dict(('any%d' % i, key_to_string(char))
                     for i, char in enumerate(wildcards))
             if 'any0' in macros:
                 macros['any'] = macros['any0']
@@ -459,7 +459,7 @@ class Actions(FileManagerAware, SettingsAware):
                         self._visual_start = None
                         startpos = min(self._visual_start_pos, len(cwd))
                     # The files between here and _visual_start_pos
-                    targets = set(cwd.files[min(startpos, newpos):\
+                    targets = set(cwd.files[min(startpos, newpos):
                             max(startpos, newpos) + 1])
                     # The selection before activating visual mode
                     old = self._previous_selection
@@ -515,7 +515,7 @@ class Actions(FileManagerAware, SettingsAware):
         # csh variable is lowercase
         cdpath = os.environ.get('CDPATH', None) or os.environ.get('cdpath', None)
         result = self.thistab.enter_dir(path, history=history)
-        if result == False and cdpath:
+        if result is False and cdpath:
             for p in cdpath.split(':'):
                 curpath = os.path.join(p, path)
                 if os.path.isdir(curpath):
@@ -645,7 +645,7 @@ class Actions(FileManagerAware, SettingsAware):
         if val is None and toggle is False:
             return
 
-        if narg == None:
+        if narg is None:
             narg = 1
         else:
             all = False
@@ -899,7 +899,7 @@ class Actions(FileManagerAware, SettingsAware):
     if version_info[0] == 3:
         def sha1_encode(self, path):
             return os.path.join(ranger.arg.cachedir,
-                    sha1(path.encode('utf-8', 'backslashreplace')) \
+                    sha1(path.encode('utf-8', 'backslashreplace'))
                             .hexdigest()) + '.jpg'
     else:
         def sha1_encode(self, path):
@@ -932,7 +932,7 @@ class Actions(FileManagerAware, SettingsAware):
 
             found = data.get((-1, -1), data.get((width, -1),
                 data.get((-1, height), data.get((width, height), False))))
-            if found == False:
+            if found is False:
                 try:
                     stat_ = os.stat(self.settings.preview_script)
                 except:
@@ -1082,7 +1082,7 @@ class Actions(FileManagerAware, SettingsAware):
         if self.restorable_tabs:
             tab = self.restorable_tabs.pop()
             for name in range(1, len(self.tabs) + 2):
-                if not name in self.tabs:
+                if name not in self.tabs:
                     self.current_tab = name
                     self.tabs[name] = tab
                     tab.enter_dir(tab.path, history=False)
@@ -1106,7 +1106,7 @@ class Actions(FileManagerAware, SettingsAware):
         if narg:
             return self.tab_open(narg, path)
         for i in range(1, 10):
-            if not i in self.tabs:
+            if i not in self.tabs:
                 return self.tab_open(i, path)
 
     def tab_switch(self, path, create_directory=False):
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index d4a24bb0..a827bb6c 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -70,7 +70,7 @@ class FM(Actions, SignalDispatcher):
         self.hostname = socket.gethostname()
         self.home_path = os.path.expanduser('~')
 
-        self.log.append('ranger {0} started! Process ID is {1}.' \
+        self.log.append('ranger {0} started! Process ID is {1}.'
                 .format(__version__, os.getpid()))
         self.log.append('Running on Python ' + sys.version.replace('\n', ''))
 
@@ -140,7 +140,7 @@ class FM(Actions, SignalDispatcher):
                     re.match(r'^(feh|sxiv|imv|pqiv) ', command):
 
                 images = [f.relative_path for f in self.thisdir.files if f.image]
-                escaped_filenames = " ".join(shell_quote(f) \
+                escaped_filenames = " ".join(shell_quote(f)
                         for f in images if "\x00" not in f)
 
                 if images and self.thisfile.relative_path in images and \
@@ -154,7 +154,7 @@ class FM(Actions, SignalDispatcher):
 
                     if command[0:4] == 'feh ':
                         new_command = command.replace("feh ",
-                            "feh --start-at %s " % \
+                            "feh --start-at %s " %
                             shell_quote(self.thisfile.relative_path), 1)
 
                     if command[0:4] == 'imv ':
@@ -165,7 +165,7 @@ class FM(Actions, SignalDispatcher):
                     if command[0:5] == 'pqiv ':
                         number = images.index(self.thisfile.relative_path)
                         new_command = command.replace("pqiv ",
-                                "pqiv --action \"goto_file_byindex(%d)\" " % \
+                                "pqiv --action \"goto_file_byindex(%d)\" " %
                                 number, 1)
 
                     if new_command:
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index aebd6efe..bae0e54d 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -94,7 +94,7 @@ class CopyLoader(Loadable, FileManagerAware):
                         if tf == f.path or str(tf).startswith(f.path):
                             tag = self.fm.tags.tags[tf]
                             self.fm.tags.remove(tf)
-                            self.fm.tags.tags[tf.replace(f.path, self.original_path \
+                            self.fm.tags.tags[tf.replace(f.path, self.original_path
                                     + '/' + f.basename)] = tag
                             self.fm.tags.dump()
                     d = 0
@@ -211,10 +211,10 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
                 except select.error:
                     sleep(0.03)
             if not self.silent:
-                for l in process.stderr.readlines():
+                for line in process.stderr:
                     if py3:
-                        l = safeDecode(l)
-                    self.fm.notify(l, bad=True)
+                        line = safeDecode(line)
+                    self.fm.notify(line, bad=True)
             if self.read:
                 read = process.stdout.read()
                 if py3:
@@ -271,6 +271,9 @@ def safeDecode(string):
 
 
 class Loader(FileManagerAware):
+    """
+    The Manager of 'Loadable' objects, referenced as fm.loader
+    """
     seconds_of_work_time = 0.03
     throbber_chars = r'/-\|'
     throbber_paused = '#'
@@ -305,6 +308,7 @@ class Loader(FileManagerAware):
             self.queue.append(obj)
         else:
             self.queue.appendleft(obj)
+        self.fm.signal_emit("loader.before", loadable=obj, fm=self.fm)
         if self.paused:
             obj.pause()
         else:
@@ -341,6 +345,7 @@ class Loader(FileManagerAware):
                 item = self.queue[index]
             if hasattr(item, 'unload'):
                 item.unload()
+            self.fm.signal_emit("loader.destroy", loadable=item, fm=self.fm)
             item.destroy()
             del self.queue[index]
             if item.progressbar_supported:
@@ -408,6 +413,7 @@ class Loader(FileManagerAware):
     def _remove_current_process(self, item):
         item.load_generator = None
         self.queue.remove(item)
+        self.fm.signal_emit("loader.after", loadable=item, fm=self.fm)
         if item.progressbar_supported:
             self.fm.ui.status.request_redraw()
 
diff --git a/ranger/core/main.py b/ranger/core/main.py
index fed4a231..77e06861 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -29,14 +29,14 @@ def main():
     else:
         os.environ[level] = '1'
 
-    if not 'SHELL' in os.environ:
+    if 'SHELL' not in os.environ:
         os.environ['SHELL'] = 'sh'
 
     ranger.arg = arg = parse_arguments()
     if arg.copy_config is not None:
         fm = FM()
         fm.copy_config_files(arg.copy_config)
-        return 1 if arg.fail_unless_cd else 0 # COMPAT
+        return 1 if arg.fail_unless_cd else 0  # COMPAT
     if arg.list_tagged_files:
         fm = FM()
         try:
@@ -53,7 +53,7 @@ def main():
                         sys.stdout.write(line[2:])
                 elif len(line) > 0 and '*' in arg.list_tagged_files:
                     sys.stdout.write(line)
-        return 1 if arg.fail_unless_cd else 0 # COMPAT
+        return 1 if arg.fail_unless_cd else 0  # COMPAT
 
     SettingsAware._setup(Settings())
 
@@ -85,7 +85,7 @@ def main():
             rifle = Rifle(rifleconf)
             rifle.reload_config()
             rifle.execute(targets, number=ranger.arg.mode, flags=ranger.arg.flags)
-            return 1 if arg.fail_unless_cd else 0 # COMPAT
+            return 1 if arg.fail_unless_cd else 0  # COMPAT
 
     crash_traceback = None
     try:
@@ -104,7 +104,7 @@ def main():
             for key in range(33, 127):
                 if key not in maps:
                     print(chr(key))
-            return 1 if arg.fail_unless_cd else 0 # COMPAT
+            return 1 if arg.fail_unless_cd else 0  # COMPAT
 
         if not sys.stdin.isatty():
             sys.stderr.write("Error: Must run ranger from terminal\n")
@@ -170,7 +170,7 @@ def main():
             except:
                 pass
             print(crash_traceback)
-            print("ranger crashed.  " \
+            print("ranger crashed.  "
                 "Please report this traceback at:")
             print("https://github.com/hut/ranger/issues")
             return 1
@@ -241,7 +241,7 @@ def parse_arguments():
     arg.confdir = expanduser(arg.confdir)
     arg.cachedir = expanduser(default_cachedir)
 
-    if arg.fail_unless_cd: # COMPAT
+    if arg.fail_unless_cd:  # COMPAT
         sys.stderr.write("Warning: The option --fail-unless-cd is deprecated.\n"
             "It was used to faciliate using ranger as a file launcher.\n"
             "Now, please use the standalone file launcher 'rifle' instead.\n")
@@ -292,7 +292,7 @@ def load_settings(fm, clean):
         # XXX Load plugins (experimental)
         try:
             plugindir = fm.confpath('plugins')
-            plugins = [p[:-3] for p in os.listdir(plugindir) \
+            plugins = [p[:-3] for p in os.listdir(plugindir)
                     if p.endswith('.py') and not p.startswith('_')]
         except:
             pass
@@ -354,7 +354,7 @@ def allow_access_to_confdir(confdir, allow):
                 print("To run ranger without the need for configuration")
                 print("files, use the --clean option.")
                 raise SystemExit()
-        if not confdir in sys.path:
+        if confdir not in sys.path:
             sys.path[0:0] = [confdir]
     else:
         if sys.path[0] == confdir:
diff --git a/ranger/core/runner.py b/ranger/core/runner.py
index 0ae227a6..62da3ff7 100644
--- a/ranger/core/runner.py
+++ b/ranger/core/runner.py
@@ -146,7 +146,7 @@ class Runner(object):
         # Set default shell for Popen
         if popen_kws['shell']:
             # This doesn't work with fish, see #300
-            if not 'fish' in os.environ['SHELL']:
+            if 'fish' not in os.environ['SHELL']:
                 popen_kws['executable'] = os.environ['SHELL']
 
         if 'stdout' not in popen_kws:
@@ -174,7 +174,7 @@ class Runner(object):
             toggle_ui = False
             context.wait = False
         if 'w' in context.flags:
-            if not pipe_output and context.wait: # <-- sanity check
+            if not pipe_output and context.wait:  # <-- sanity check
                 wait_for_enter = True
         if 'r' in context.flags:
             # TODO: make 'r' flag work with pipes
diff --git a/ranger/core/tab.py b/ranger/core/tab.py
index dc76568b..2faf4b0c 100644
--- a/ranger/core/tab.py
+++ b/ranger/core/tab.py
@@ -103,7 +103,7 @@ class Tab(FileManagerAware, SettingsAware):
     def inherit_history(self, other_history):
         self.history.rebase(other_history)
 
-    def enter_dir(self, path, history = True):
+    def enter_dir(self, path, history=True):
         """Enter given path"""
         # TODO: Ensure that there is always a self.thisdir
         if path is None: return
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 61967b02..1ee421d7 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -114,11 +114,11 @@ class W3MImageDisplayer(ImageDisplayer):
         fontw, fonth = self._get_font_dimensions()
 
         cmd = "6;{x};{y};{w};{h}\n4;\n3;\n".format(
-                x = int((start_x - 0.2) * fontw),
-                y = start_y * fonth,
+                x=int((start_x - 0.2) * fontw),
+                y=start_y * fonth,
                 # y = int((start_y + 1) * fonth), # (for tmux top status bar)
-                w = int((width + 0.4) * fontw),
-                h = height * fonth + 1)
+                w=int((width + 0.4) * fontw),
+                h=height * fonth + 1)
                 # h = (height - 1) * fonth + 1) # (for tmux top status bar)
 
         try:
@@ -168,12 +168,12 @@ class W3MImageDisplayer(ImageDisplayer):
             height = max_height_pixels
 
         return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format(
-                x = int((start_x - 0.2) * fontw),
-                y = start_y * fonth,
+                x=int((start_x - 0.2) * fontw),
+                y=start_y * fonth,
                 # y = (start_y + 1) * fonth, # (for tmux top status bar)
-                w = width,
-                h = height,
-                filename = path)
+                w=width,
+                h=height,
+                filename=path)
 
     def quit(self):
         if self.is_initialized and self.process and self.process.poll() is None:
diff --git a/ranger/ext/keybinding_parser.py b/ranger/ext/keybinding_parser.py
index 4e9375bf..84a4a068 100644
--- a/ranger/ext/keybinding_parser.py
+++ b/ranger/ext/keybinding_parser.py
@@ -235,7 +235,7 @@ class KeyBuffer(object):
         if not self.finished_parsing_quantifier and key in digits:
             if self.quantifier is None:
                 self.quantifier = 0
-            self.quantifier = self.quantifier * 10 + key - 48 # (48 = ord(0))
+            self.quantifier = self.quantifier * 10 + key - 48  # (48 = ord(0))
         else:
             self.finished_parsing_quantifier = True
 
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index b1467c34..08515cb0 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -169,7 +169,7 @@ class Rifle(object):
                 command = command.strip()
                 self.rules.append((command, tests))
             except Exception as e:
-                self.hook_logger("Syntax error in %s line %d (%s)" % \
+                self.hook_logger("Syntax error in %s line %d (%s)" %
                     (config_file, lineno, str(e)))
         f.close()
 
diff --git a/ranger/ext/shell_escape.py b/ranger/ext/shell_escape.py
index 44984405..fe542084 100644
--- a/ranger/ext/shell_escape.py
+++ b/ranger/ext/shell_escape.py
@@ -5,7 +5,7 @@
 
 META_CHARS = (' ', "'", '"', '`', '&', '|', ';',
         '$', '!', '(', ')', '[', ']', '<', '>', '\t')
-UNESCAPABLE = set(map(chr, list(range(9)) + list(range(10, 32)) \
+UNESCAPABLE = set(map(chr, list(range(9)) + list(range(10, 32))
         + list(range(127, 256))))
 META_DICT = dict([(mc, '\\' + mc) for mc in META_CHARS])
 
@@ -20,7 +20,7 @@ def shell_escape(arg):
     arg = str(arg)
     if UNESCAPABLE & set(arg):
         return shell_quote(arg)
-    arg = arg.replace('\\', '\\\\') # make sure this comes at the start
+    arg = arg.replace('\\', '\\\\')  # make sure this comes at the start
     for k, v in META_DICT.items():
         arg = arg.replace(k, v)
     return arg
diff --git a/ranger/gui/ansi.py b/ranger/gui/ansi.py
index 57a69442..ffa9425c 100644
--- a/ranger/gui/ansi.py
+++ b/ranger/gui/ansi.py
@@ -149,7 +149,7 @@ def char_slice(ansi_text, start, length):
         old_pos = pos
         pos += len(chunk)
         if pos <= start:
-            pass # seek
+            pass  # seek
         elif old_pos < start and pos >= start:
             chunks.append(last_color)
             chunks.append(chunk[start-old_pos:start-old_pos+length])
diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py
index fa553aea..9572c649 100644
--- a/ranger/gui/colorscheme.py
+++ b/ranger/gui/colorscheme.py
@@ -51,7 +51,7 @@ class ColorScheme(object):
         """
         context = Context(keys)
         color = self.use(context)
-        if len(color) != 3 or not all(isinstance(value, int) \
+        if len(color) != 3 or not all(isinstance(value, int)
                 for value in color):
             raise ValueError("Bad Value from colorscheme.  Need "
                 "a tuple of (foreground_color, background_color, attribute).")
diff --git a/ranger/gui/context.py b/ranger/gui/context.py
index d5352a0a..e577d2be 100644
--- a/ranger/gui/context.py
+++ b/ranger/gui/context.py
@@ -13,8 +13,8 @@ CONTEXT_KEYS = ['reset', 'error', 'badinfo',
         'space', 'permissions', 'owner', 'group', 'mtime', 'nlink',
         'scroll', 'all', 'bot', 'top', 'percentage', 'filter',
         'flat', 'marked', 'tagged', 'tag_marker', 'cut', 'copied',
-        'help_markup', # COMPAT
-        'seperator', 'key', 'special', 'border', # COMPAT
+        'help_markup',  # COMPAT
+        'seperator', 'key', 'special', 'border',  # COMPAT
         'title', 'text', 'highlight', 'bars', 'quotes', 'tab', 'loaded',
         'keybuffer',
         'infostring',
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 200f3625..7e873f4c 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -27,12 +27,12 @@ def _setup_mouse(signal):
         curses.mousemask(MOUSEMASK)
         curses.mouseinterval(0)
 
-        ## this line solves this problem:
-        ## If a mouse click triggers an action that disables curses and
-        ## starts curses again, (e.g. running a ## file by clicking on its
-        ## preview) and the next key is another mouse click, the bstate of this
-        ## mouse event will be invalid.  (atm, invalid bstates are recognized
-        ## as scroll-down, so this avoids an errorneous scroll-down action)
+        # This line solves this problem:
+        # If a mouse click triggers an action that disables curses and
+        # starts curses again, (e.g. running a ## file by clicking on its
+        # preview) and the next key is another mouse click, the bstate of this
+        # mouse event will be invalid.  (atm, invalid bstates are recognized
+        # as scroll-down, so this avoids an errorneous scroll-down action)
         curses.ungetmouse(0, 0, 0, 0, 0)
     else:
         curses.mousemask(0)
@@ -93,7 +93,7 @@ class UI(DisplayableContainer):
             self.setup()
             self.win.addstr("loading...")
             self.win.refresh()
-            self._draw_title = curses.tigetflag('hs') # has_status_line
+            self._draw_title = curses.tigetflag('hs')  # has_status_line
 
         self.update_size()
         self.is_on = True
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 0a73e013..c7ef4780 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -302,7 +302,7 @@ class BrowserColumn(Pager):
 
             text = current_linemode.filetitle(drawn, metadata)
 
-            if drawn.marked and (self.main_column or \
+            if drawn.marked and (self.main_column or
                     self.settings.display_tags_in_all_columns):
                 text = " " + text
 
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 64474ac7..8bb37937 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -469,7 +469,7 @@ class Console(Widget):
                 self.pos = len(tab_result)
                 self.on_line_change()
 
-            elif tab_result == None:
+            elif tab_result is None:
                 pass
 
             elif hasattr(tab_result, '__iter__'):
diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py
index 654c63be..f05606c9 100644
--- a/ranger/gui/widgets/taskview.py
+++ b/ranger/gui/widgets/taskview.py
@@ -52,7 +52,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" % \
+                        self.addstr(y, 0, "%3.2f%% - %s" %
                                 (obj.percent, descr), self.wid)
                         wid = int(self.wid / 100.0 * obj.percent)
                         self.color_at(y, 0, self.wid, tuple(clr))
diff --git a/ranger/gui/widgets/view_base.py b/ranger/gui/widgets/view_base.py
index 613353c3..f487d357 100644
--- a/ranger/gui/widgets/view_base.py
+++ b/ranger/gui/widgets/view_base.py
@@ -63,8 +63,8 @@ class ViewBase(Widget, DisplayableContainer):
         self.color_reset()
         self.need_clear = True
 
-        sorted_bookmarks = sorted((item for item in self.fm.bookmarks \
-            if self.fm.settings.show_hidden_bookmarks or \
+        sorted_bookmarks = sorted((item for item in self.fm.bookmarks
+            if self.fm.settings.show_hidden_bookmarks or
             '/.' not in item[1].path), key=lambda t: t[0].lower())
 
         hei = min(self.hei - 1, len(sorted_bookmarks))
diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py
index 2c0bc300..bf60f485 100644
--- a/ranger/gui/widgets/view_miller.py
+++ b/ranger/gui/widgets/view_miller.py
@@ -209,16 +209,16 @@ class ViewMiller(ViewBase):
                     continue
 
             if i == last_i - 1:
-                self.pager.resize(pad, left, hei - pad * 2, \
+                self.pager.resize(pad, left, hei - pad * 2,
                         max(1, self.wid - left - pad))
 
                 if cut_off:
-                    self.columns[i].resize(pad, left, hei - pad * 2, \
+                    self.columns[i].resize(pad, left, hei - pad * 2,
                             max(1, self.wid - left - pad))
                     continue
 
             try:
-                self.columns[i].resize(pad, left, hei - pad * 2, \
+                self.columns[i].resize(pad, left, hei - pad * 2,
                         max(1, wid - 1))
             except KeyError:
                 pass
diff --git a/setup.py b/setup.py
index c2b6da17..6838cdc0 100755
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ import ranger
 
 
 def _findall(directory):
-    return [os.path.join(directory, f) for f in os.listdir(directory) \
+    return [os.path.join(directory, f) for f in os.listdir(directory)
             if os.path.isfile(os.path.join(directory, f))]
 
 if __name__ == '__main__':