about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRodrigo Stuchi <rod.stuchi@gmail.com>2018-05-15 21:51:20 -0300
committerRodrigo Stuchi <rod.stuchi@gmail.com>2018-05-15 21:51:20 -0300
commit591c7ce7c2d406e9e7de506c9ee49f8b6468539e (patch)
tree29a133d4c2eff64be4379ab9a00a9d3220513a78
parent8a8ad05bb64e595fe8ac0196e850445ea704f269 (diff)
downloadranger-591c7ce7c2d406e9e7de506c9ee49f8b6468539e.tar.gz
remove unnecessary if statement, uses lazy_property
-rwxr-xr-xranger/config/commands.py8
-rw-r--r--ranger/container/fsobject.py6
2 files changed, 7 insertions, 7 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index bf03069f..7f5fc764 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1727,7 +1727,7 @@ class yank(Command):
 
     modes = {
         '': 'basename',
-        'name_without_extension': 'splitext',
+        'name_without_extension': 'basename_without_extension',
         'name': 'basename',
         'dir': 'dirname',
         'path': 'path',
@@ -1761,11 +1761,7 @@ class yank(Command):
         clipboard_commands = clipboards()
 
         mode = self.modes[self.arg(1)]
-        if mode == "splitext":
-            selection = [os.path.splitext(item)[0] for item in
-                         self.get_selection_attr('basename')]
-        else:
-            selection = self.get_selection_attr(mode)
+        selection = self.get_selection_attr(mode)
 
         new_clipboard_contents = "\n".join(selection)
         for command in clipboard_commands:
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 0c9f70f6..37151ecf 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -6,7 +6,7 @@ from __future__ import (absolute_import, division, print_function)
 import re
 from grp import getgrgid
 from os import lstat, stat
-from os.path import abspath, basename, dirname, realpath, relpath
+from os.path import abspath, basename, dirname, realpath, relpath, splitext
 from pwd import getpwuid
 from time import time
 
@@ -171,6 +171,10 @@ class FileSystemObject(  # pylint: disable=too-many-instance-attributes,too-many
         return basename_list
 
     @lazy_property
+    def basename_without_extension(self):
+        return splitext(self.basename)[0]
+
+    @lazy_property
     def safe_basename(self):
         return self.basename.translate(_SAFE_STRING_TABLE)