From fc972ea21dc9240a4b7147cc24674cdfa2aec11b Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 25 Dec 2009 07:21:37 +0100 Subject: improved paste-generators --- ranger/actions.py | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/ranger/actions.py b/ranger/actions.py index 3dac209f..7a1215df 100644 --- a/ranger/actions.py +++ b/ranger/actions.py @@ -190,31 +190,46 @@ class Actions(EnvironmentAware, SettingsAware): from os.path import join, isdir from ranger.ext import shutil_generatorized as shutil_g from ranger.fsobject.loader import LoadableObject - copied_files = self.env.copy + copied_files = tuple(self.env.copy) if not copied_files: return + pwd = self.env.pwd + try: + one_file = copied_files[0] + except: + one_file = None + if self.env.cut: - for f in self.env.copy: - self.loader.add(LoadableObject(\ - shutil_g.move(f.path, self.env.pwd.path),\ - "moving: " + f.path)) self.env.copy.clear() self.env.cut = False + if len(copied_files) == 1: + descr = "moving: " + one_file.path + else: + descr = "moving files from: " + one_file.dirname + def generate(): + for f in copied_files: + for _ in shutil_g.move(f.path, pwd.path): + yield + pwd.load_content() else: - for f in self.env.copy: - if isdir(f.path): - self.loader.add(LoadableObject( - shutil_g.copytree(f.path, - join(self.env.pwd.path, f.basename)), - "copying tree: " + str(f.path))) - else: - self.loader.add(LoadableObject( - shutil_g.copy2(f.path, self.env.pwd.path), - "copying: " + str(f.path))) - - self.env.pwd.load_content() + if len(copied_files) == 1: + descr = "copying: " + one_file.path + else: + descr = "copying files from: " + one_file.dirname + def generate(): + for f in self.env.copy: + if isdir(f.path): + for _ in shutil_g.copytree(f.path, + join(self.env.pwd.path, f.basename)): + yield + else: + for _ in shutil_g.copy2(f.path, self.env.pwd.path): + yield + pwd.load_content() + + self.loader.add(LoadableObject(generate(), descr)) def delete(self): msg = self.notify("Deleting ...", duration=0) -- cgit 1.4.1-2-gfad0