From 80d517985a0525ffc4b3a1343f67c7d7e63d6c76 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 12 Apr 2015 15:11:34 +0200 Subject: config/commands.py: deduplication --- ranger/config/commands.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 6b36350b..93254350 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -850,13 +850,12 @@ class bulkrename(Command): cmdfile = tempfile.NamedTemporaryFile() cmdfile.write(b"# This file will be executed when you close the editor.\n") cmdfile.write(b"# Please double-check everything, clear the file to abort.\n") + content = "\n".join("mv -vi -- " + esc(old) + " " + esc(new) \ + for old, new in zip(filenames, new_filenames) if old != new) if py3: - cmdfile.write("\n".join("mv -vi -- " + esc(old) + " " + esc(new) \ - for old, new in zip(filenames, new_filenames) \ - if old != new).encode("utf-8")) + cmdfile.write(content.encode("utf-8")) else: - cmdfile.write("\n".join("mv -vi -- " + esc(old) + " " + esc(new) \ - for old, new in zip(filenames, new_filenames) if old != new)) + cmdfile.write(content) cmdfile.flush() # Open the script and let the user review it, then check if the script -- cgit 1.4.1-2-gfad0