diff options
author | hut <hut@lepus.uberspace.de> | 2016-06-21 01:18:24 +0200 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2016-06-21 01:18:24 +0200 |
commit | 92855e6d1179c425a5d70a5c7235027e2350753b (patch) | |
tree | d749da9032086371b798bc52a6da1dbb2377d990 /ranger | |
parent | b208184407d0881daa61dd92eb196354f1bdff1e (diff) | |
parent | d4598be62b8913b339c8c482baaab294b63364ec (diff) | |
download | ranger-92855e6d1179c425a5d70a5c7235027e2350753b.tar.gz |
Merge branch 'backslash' of https://github.com/stepshal/ranger
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/api/commands.py | 12 | ||||
-rwxr-xr-x | ranger/config/commands.py | 24 | ||||
-rw-r--r-- | ranger/container/directory.py | 4 | ||||
-rw-r--r-- | ranger/container/fsobject.py | 4 | ||||
-rw-r--r-- | ranger/container/settings.py | 2 | ||||
-rw-r--r-- | ranger/core/actions.py | 6 | ||||
-rw-r--r-- | ranger/core/fm.py | 8 | ||||
-rw-r--r-- | ranger/core/loader.py | 2 | ||||
-rw-r--r-- | ranger/core/main.py | 4 | ||||
-rwxr-xr-x | ranger/ext/rifle.py | 2 | ||||
-rw-r--r-- | ranger/ext/shell_escape.py | 2 | ||||
-rw-r--r-- | ranger/gui/colorscheme.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/taskview.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/view_base.py | 4 | ||||
-rw-r--r-- | ranger/gui/widgets/view_miller.py | 6 |
16 files changed, 43 insertions, 43 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py index 8ba2a3a0..7021ed7c 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 @@ -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 06cc8059..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)) @@ -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/container/directory.py b/ranger/container/directory.py index 4efc6b37..923821a0 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -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 ebe76cdb..b6c0c9ec 100644 --- a/ranger/container/fsobject.py +++ b/ranger/container/fsobject.py @@ -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 diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 23f3bad0..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': diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 0e9b0748..2c8371a0 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -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 @@ -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): 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 d265ce80..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 diff --git a/ranger/core/main.py b/ranger/core/main.py index 042926aa..77e06861 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -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 @@ -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 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 91736228..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]) 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/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/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 |