diff options
author | hut <hut@lavabit.com> | 2009-12-25 07:21:37 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-25 07:21:37 +0100 |
commit | fc972ea21dc9240a4b7147cc24674cdfa2aec11b (patch) | |
tree | 28710130fc024d4a6e00614a31a3e4ac030b6a89 | |
parent | 4781d4246e24105809c26e1b93b772533e1ad61c (diff) | |
download | ranger-fc972ea21dc9240a4b7147cc24674cdfa2aec11b.tar.gz |
improved paste-generators
-rw-r--r-- | ranger/actions.py | 49 |
1 files 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) |