diff options
author | hut <hut@lavabit.com> | 2009-12-25 06:04:49 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-25 06:04:49 +0100 |
commit | 1743e8b97744bc4dbb9277e9de36c3bec31cd428 (patch) | |
tree | 603c7265b59a73494078848c6a6c714ea272be76 /ranger | |
parent | 56134d8a42dfc0a88bab898aa8418e5c3837af16 (diff) | |
download | ranger-1743e8b97744bc4dbb9277e9de36c3bec31cd428.tar.gz |
made copying processes work with the loader
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/actions.py | 29 | ||||
-rw-r--r-- | ranger/fsobject/loader.py | 9 |
2 files changed, 21 insertions, 17 deletions
diff --git a/ranger/actions.py b/ranger/actions.py index 08495ce8..3dac209f 100644 --- a/ranger/actions.py +++ b/ranger/actions.py @@ -188,36 +188,31 @@ class Actions(EnvironmentAware, SettingsAware): def paste(self): """Paste the selected items into the current directory""" 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 if not copied_files: return if self.env.cut: - msg = self.notify("Moving ...", duration=0) - self.ui.redraw() for f in self.env.copy: - try: - shutil.move(f.path, self.env.pwd.path) - except (shutil.Error, IOError, OSError) as x: - self.notify(str(x), bad=True) + self.loader.add(LoadableObject(\ + shutil_g.move(f.path, self.env.pwd.path),\ + "moving: " + f.path)) self.env.copy.clear() self.env.cut = False else: - msg = self.notify("Copying ...", duration=0) - self.ui.redraw() for f in self.env.copy: if isdir(f.path): - try: - shutil.copytree(f.path, join(self.env.pwd.path, f.basename)) - except (shutil.Error, IOError, OSError) as x: - self.notify(str(x), bad=True) + self.loader.add(LoadableObject( + shutil_g.copytree(f.path, + join(self.env.pwd.path, f.basename)), + "copying tree: " + str(f.path))) else: - try: - shutil.copy(f.path, self.env.pwd.path) - except (shutil.Error, IOError, OSError) as x: - self.notify(str(x), bad=True) - msg.delete() + self.loader.add(LoadableObject( + shutil_g.copy2(f.path, self.env.pwd.path), + "copying: " + str(f.path))) self.env.pwd.load_content() diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py index 7b051d53..aaf38117 100644 --- a/ranger/fsobject/loader.py +++ b/ranger/fsobject/loader.py @@ -11,6 +11,15 @@ def status_generator(): yield '\\' yield '|' +class LoadableObject(object): + def __init__(self, gen, descr): + self.load_generator = gen + self.description = descr + + def get_description(self): + return self.description + + class Loader(object): seconds_of_work_time = 0.05 |