From c2469bcfbb19394ac358ef1a97a4ae4a18259f82 Mon Sep 17 00:00:00 2001 From: Toon Nolten Date: Sun, 28 May 2017 15:24:29 +0200 Subject: Locally import subprocess; improve docstring; give a more meaningful name to input_argument --- 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 8f606cbe..16b48c49 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -88,7 +88,6 @@ from __future__ import (absolute_import, division, print_function) from collections import deque import os import re -import subprocess from ranger.api.commands import Command @@ -1676,7 +1675,7 @@ class linemode(default_linemode): class yank(Command): """:yank [name|dir|path] - Copies the file's name(default), directory or path into both the primary X + Copies the file's name (default), directory or path into both the primary X selection and the clipboard. """ @@ -1688,6 +1687,7 @@ class yank(Command): } def execute(self): + import subprocess def clipboards(): from ranger.ext.get_executables import get_executables clipboard_managers = { @@ -1708,17 +1708,16 @@ class yank(Command): for manager in ordered_managers: if manager in executables: return clipboard_managers[manager] - return [] clipboard_commands = clipboards() selection = self.get_selection_attr(self.modes[self.arg(1)]) - input_argument = "\n".join(selection) + new_clipboard_contents = "\n".join(selection) for command in clipboard_commands: process = subprocess.Popen(command, universal_newlines=True, stdin=subprocess.PIPE) - process.communicate(input=input_argument) + process.communicate(input=new_clipboard_contents) def get_selection_attr(self, attr): return [getattr(item, attr) for item in -- cgit 1.4.1-2-gfad0