diff options
-rwxr-xr-x | ranger/config/commands.py | 8 | ||||
-rw-r--r-- | ranger/config/commands_sample.py | 2 | ||||
-rw-r--r-- | ranger/container/directory.py | 6 | ||||
-rw-r--r-- | ranger/container/fsobject.py | 2 | ||||
-rw-r--r-- | ranger/container/settings.py | 4 | ||||
-rw-r--r-- | ranger/core/actions.py | 14 | ||||
-rw-r--r-- | ranger/core/loader.py | 12 | ||||
-rw-r--r-- | ranger/core/main.py | 4 | ||||
-rw-r--r-- | ranger/core/runner.py | 2 | ||||
-rw-r--r-- | ranger/core/tab.py | 2 | ||||
-rw-r--r-- | ranger/ext/img_display.py | 18 | ||||
-rw-r--r-- | ranger/gui/ui.py | 12 | ||||
-rw-r--r-- | ranger/gui/widgets/console.py | 2 |
13 files changed, 47 insertions, 41 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index cb4fd3a8..06cc8059 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -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() 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 4c69e7c9..4efc6b37 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: @@ -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() diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py index 78405e99..ebe76cdb 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) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index de39c013..23f3bad0 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -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 642eec04..0e9b0748 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) @@ -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 @@ -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/loader.py b/ranger/core/loader.py index aebd6efe..d265ce80 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -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 73f8a03c..042926aa 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -29,7 +29,7 @@ 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() @@ -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 849b849c..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: 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/gui/ui.py b/ranger/gui/ui.py index ed8d4d9e..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) 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__'): |