From 5348e120aa6d39604b2426577f84669b9ce0aa24 Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 21 Jun 2016 19:09:34 +0700 Subject: Put colon-separated compound statement on separate lines. --- ranger/__init__.py | 6 ++++-- ranger/container/bookmarks.py | 9 ++++++--- ranger/core/runner.py | 12 ++++++++---- ranger/core/tab.py | 3 ++- ranger/ext/direction.py | 18 ++++++++++++------ ranger/ext/shutil_generatorized.py | 18 ++++++++++++------ ranger/gui/colorscheme.py | 9 ++++++--- ranger/gui/widgets/view_miller.py | 3 ++- 8 files changed, 52 insertions(+), 26 deletions(-) diff --git a/ranger/__init__.py b/ranger/__init__.py index 093a01d5..8b68a5b0 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -53,7 +53,8 @@ def log(*objects, **keywords): Has the same arguments as print() in python3. """ from ranger import arg - if LOGFILE is None or not arg.debug or arg.clean: return + if LOGFILE is None or not arg.debug or arg.clean: + return start = keywords.get('start', 'ranger:') sep = keywords.get('sep', ' ') end = keywords.get('end', '\n') @@ -63,7 +64,8 @@ def log(*objects, **keywords): def log_traceback(): from ranger import arg - if LOGFILE is None or not arg.debug or arg.clean: return + if LOGFILE is None or not arg.debug or arg.clean: + return import traceback traceback.print_stack(file=open(LOGFILE, 'a')) diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py index b5e7dc72..1a42fb13 100644 --- a/ranger/container/bookmarks.py +++ b/ranger/container/bookmarks.py @@ -62,7 +62,8 @@ class Bookmarks(object): def remember(self, value): """Bookmarks to the key '""" self["'"] = value - if self.autosave: self.save() + if self.autosave: + self.save() def __delitem__(self, key): """Delete the bookmark with the given key""" @@ -70,7 +71,8 @@ class Bookmarks(object): key = "'" if key in self.dct: del self.dct[key] - if self.autosave: self.save() + if self.autosave: + self.save() def __iter__(self): return iter(self.dct.items()) @@ -94,7 +96,8 @@ class Bookmarks(object): key = "'" if key in ALLOWED_KEYS: self.dct[key] = value - if self.autosave: self.save() + if self.autosave: + self.save() def __contains__(self, key): """Test whether a bookmark-key is defined""" diff --git a/ranger/core/runner.py b/ranger/core/runner.py index 62da3ff7..60e14202 100644 --- a/ranger/core/runner.py +++ b/ranger/core/runner.py @@ -102,11 +102,15 @@ class Runner(object): def _activate_ui(self, boolean): if self.ui is not None: if boolean: - try: self.ui.initialize() - except: self._log("Failed to initialize UI") + try: + self.ui.initialize() + except: + self._log("Failed to initialize UI") else: - try: self.ui.suspend() - except: self._log("Failed to suspend UI") + try: + self.ui.suspend() + except: + self._log("Failed to suspend UI") def __call__(self, action=None, try_app_first=False, app='default', files=None, mode=0, diff --git a/ranger/core/tab.py b/ranger/core/tab.py index 2faf4b0c..faaaddfd 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -106,7 +106,8 @@ class Tab(FileManagerAware, SettingsAware): def enter_dir(self, path, history=True): """Enter given path""" # TODO: Ensure that there is always a self.thisdir - if path is None: return + if path is None: + return path = str(path) # clear filter in the folder we're leaving diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index f236e7e3..7dc74a18 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -33,16 +33,22 @@ class Direction(dict): return Direction(**self) def _get_bool(self, first, second, fallback=None): - try: return self[first] + try: + return self[first] except: - try: return not self[second] - except: return fallback + try: + return not self[second] + except: + return fallback def _get_direction(self, first, second, fallback=0): - try: return self[first] + try: + return self[first] except: - try: return -self[second] - except: return fallback + try: + return -self[second] + except: + return fallback def up(self): return -Direction.down(self) diff --git a/ranger/ext/shutil_generatorized.py b/ranger/ext/shutil_generatorized.py index 1bf95842..470aff7e 100644 --- a/ranger/ext/shutil_generatorized.py +++ b/ranger/ext/shutil_generatorized.py @@ -90,14 +90,20 @@ def copystat(src, dst): st = os.lstat(src) mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): - try: os.utime(dst, (st.st_atime, st.st_mtime)) - except: pass + try: + os.utime(dst, (st.st_atime, st.st_mtime)) + except: + pass if hasattr(os, 'chmod'): - try: os.chmod(dst, mode) - except: pass + try: + os.chmod(dst, mode) + except: + pass if hasattr(os, 'chflags') and hasattr(st, 'st_flags'): - try: os.chflags(dst, st.st_flags) - except: pass + try: + os.chflags(dst, st.st_flags) + except: + pass def copy2(src, dst, overwrite=False, symlinks=False): diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py index 9572c649..595f8d42 100644 --- a/ranger/gui/colorscheme.py +++ b/ranger/gui/colorscheme.py @@ -79,7 +79,8 @@ def _colorscheme_name_to_class(signal): # then at RANGERDIR/colorschemes. If the file contains a class # named Scheme, it is used. Otherwise, an arbitrary other class # is picked. - if isinstance(signal.value, ColorScheme): return + if isinstance(signal.value, ColorScheme): + return if not signal.value: signal.value = 'default' @@ -119,10 +120,12 @@ def _colorscheme_name_to_class(signal): signal.value = ColorScheme() raise Exception("Cannot locate colorscheme `%s'" % scheme_name) else: - if usecustom: allow_access_to_confdir(ranger.arg.confdir, True) + if usecustom: + allow_access_to_confdir(ranger.arg.confdir, True) scheme_module = getattr(__import__(scheme_supermodule, globals(), locals(), [scheme_name], 0), scheme_name) - if usecustom: allow_access_to_confdir(ranger.arg.confdir, False) + if usecustom: + allow_access_to_confdir(ranger.arg.confdir, False) if hasattr(scheme_module, 'Scheme') \ and is_scheme(scheme_module.Scheme): signal.value = scheme_module.Scheme() diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index bf60f485..b7cc07a6 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -61,7 +61,8 @@ class ViewMiller(ViewBase): (self.ratios[-1] * last)) offset = 1 - len(ratios) - if self.preview: offset += 1 + if self.preview: + offset += 1 for level in range(len(ratios)): fl = BrowserColumn(self.win, level + offset) -- cgit 1.4.1-2-gfad0