Exemplo n.º 1
0
			def generate():
				for f in copied_files:
					for _ in shutil_g.move(src=f.path,
							dst=original_path,
							overwrite=overwrite):
						yield
				cwd = self.env.get_directory(original_path)
				cwd.load_content()
Exemplo n.º 2
0
 def generate(self):
     from ranger.ext import shutil_generatorized as shutil_g
     if self.copy_buffer:
         # TODO: Don't calculate size when renaming (needs detection)
         bytes_per_tick = shutil_g.BLOCK_SIZE
         size = max(1, self._calculate_size(bytes_per_tick))
         size_str = " (" + human_readable(self._calculate_size(1)) + ")"
         done = 0
         if self.do_cut:
             self.original_copy_buffer.clear()
             if len(self.copy_buffer) == 1:
                 self.description = "moving: " + self.one_file.path + size_str
             else:
                 self.description = "moving files from: " + self.one_file.dirname + size_str
             for f in self.copy_buffer:
                 for tf in self.fm.tags.tags:
                     if tf == f.path or str(tf).startswith(f.path):
                         tag = self.fm.tags.tags[tf]
                         self.fm.tags.remove(tf)
                         self.fm.tags.tags[tf.replace(
                             f.path,
                             self.original_path + '/' + f.basename)] = tag
                         self.fm.tags.dump()
                 d = 0
                 for d in shutil_g.move(src=f.path,
                                        dst=self.original_path,
                                        overwrite=self.overwrite):
                     self.percent = float(done + d) / size * 100.
                     yield
                 done += d
         else:
             if len(self.copy_buffer) == 1:
                 self.description = "copying: " + self.one_file.path + size_str
             else:
                 self.description = "copying files from: " + self.one_file.dirname + size_str
             for f in self.copy_buffer:
                 if os.path.isdir(f.path) and not os.path.islink(f.path):
                     d = 0
                     for d in shutil_g.copytree(src=f.path,
                                                dst=os.path.join(
                                                    self.original_path,
                                                    f.basename),
                                                symlinks=True,
                                                overwrite=self.overwrite):
                         self.percent = float(done + d) / size * 100.
                         yield
                     done += d
                 else:
                     d = 0
                     for d in shutil_g.copy2(f.path,
                                             self.original_path,
                                             symlinks=True,
                                             overwrite=self.overwrite):
                         self.percent = float(done + d) / size * 100.
                         yield
                     done += d
         cwd = self.fm.get_directory(self.original_path)
         cwd.load_content()
Exemplo n.º 3
0
    def generate(self):
        if not self.copy_buffer:
            return

        from ranger.ext import shutil_generatorized as shutil_g
        # TODO: Don't calculate size when renaming (needs detection)
        bytes_per_tick = shutil_g.BLOCK_SIZE
        size = max(1, self._calculate_size(bytes_per_tick))
        size_str = " (" + human_readable(self._calculate_size(1)) + ")"
        done = 0
        if self.do_cut:
            self.original_copy_buffer.clear()
            if len(self.copy_buffer) == 1:
                self.description = "moving: " + self.one_file.path + size_str
            else:
                self.description = "moving files from: " + self.one_file.dirname + size_str
            for fobj in self.copy_buffer:
                for path in self.fm.tags.tags:
                    if path == fobj.path or str(path).startswith(fobj.path):
                        tag = self.fm.tags.tags[path]
                        self.fm.tags.remove(path)
                        self.fm.tags.tags[
                            path.replace(fobj.path, path.join(self.original_path, fobj.basename))
                        ] = tag
                        self.fm.tags.dump()
                n = 0
                for n in shutil_g.move(src=fobj.path, dst=self.original_path,
                                       overwrite=self.overwrite):
                    self.percent = ((done + n) / size) * 100.
                    yield
                done += n
        else:
            if len(self.copy_buffer) == 1:
                self.description = "copying: " + self.one_file.path + size_str
            else:
                self.description = "copying files from: " + self.one_file.dirname + size_str
            for fobj in self.copy_buffer:
                if os.path.isdir(fobj.path) and not os.path.islink(fobj.path):
                    n = 0
                    for n in shutil_g.copytree(
                            src=fobj.path,
                            dst=os.path.join(self.original_path, fobj.basename),
                            symlinks=True,
                            overwrite=self.overwrite,
                    ):
                        self.percent = ((done + n) / size) * 100.
                        yield
                    done += n
                else:
                    n = 0
                    for n in shutil_g.copy2(fobj.path, self.original_path,
                                            symlinks=True, overwrite=self.overwrite):
                        self.percent = ((done + n) / size) * 100.
                        yield
                    done += n
        cwd = self.fm.get_directory(self.original_path)
        cwd.load_content()
Exemplo n.º 4
0
 def generate(self):
     from ranger.ext import shutil_generatorized as shutil_g
     if self.copy_buffer:
         # TODO: Don't calculate size when renaming (needs detection)
         bytes_per_tick = shutil_g.BLOCK_SIZE
         size = max(1, self._calculate_size(bytes_per_tick))
         size_str = " (" + human_readable(self._calculate_size(1)) + ")"
         done = 0
         if self.do_cut:
             self.original_copy_buffer.clear()
             if len(self.copy_buffer) == 1:
                 self.description = "moving: " + self.one_file.path + size_str
             else:
                 self.description = "moving files from: " + self.one_file.dirname + size_str
             for f in self.copy_buffer:
                 for tf in self.fm.tags.tags:
                     if tf == f.path or str(tf).startswith(f.path):
                         tag = self.fm.tags.tags[tf]
                         self.fm.tags.remove(tf)
                         self.fm.tags.tags[tf.replace(f.path, self.original_path
                                 + '/' + f.basename)] = tag
                         self.fm.tags.dump()
                 d = 0
                 for d in shutil_g.move(src=f.path,
                         dst=self.original_path,
                         overwrite=self.overwrite):
                     self.percent = float(done + d) / size * 100.
                     yield
                 done += d
         else:
             if len(self.copy_buffer) == 1:
                 self.description = "copying: " + self.one_file.path + size_str
             else:
                 self.description = "copying files from: " + self.one_file.dirname + size_str
             for f in self.copy_buffer:
                 if os.path.isdir(f.path) and not os.path.islink(f.path):
                     d = 0
                     for d in shutil_g.copytree(src=f.path,
                             dst=os.path.join(self.original_path, f.basename),
                             symlinks=True,
                             overwrite=self.overwrite):
                         self.percent = float(done + d) / size * 100.
                         yield
                     done += d
                 else:
                     d = 0
                     for d in shutil_g.copy2(f.path, self.original_path,
                             symlinks=True,
                             overwrite=self.overwrite):
                         self.percent = float(done + d) / size * 100.
                         yield
                     done += d
         cwd = self.fm.get_directory(self.original_path)
         cwd.load_content()
Exemplo n.º 5
0
 def generate(self):
     from ranger.ext import shutil_generatorized as shutil_g
     if self.copy_buffer:
         # TODO: Don't calculate size when renaming (needs detection)
         bytes_per_tick = shutil_g.BLOCK_SIZE
         size = max(1, self._calculate_size(bytes_per_tick))
         bar_tick = 100.0 / (float(size) / bytes_per_tick)
         if self.do_cut:
             self.original_copy_buffer.clear()
             if len(self.copy_buffer) == 1:
                 self.description = "moving: " + self.one_file.path
             else:
                 self.description = "moving files from: " + self.one_file.dirname
             for f in self.copy_buffer:
                 for _ in shutil_g.move(src=f.path,
                                        dst=self.original_path,
                                        overwrite=self.overwrite):
                     self.percent += bar_tick
                     yield
         else:
             if len(self.copy_buffer) == 1:
                 self.description = "copying: " + self.one_file.path
             else:
                 self.description = "copying files from: " + self.one_file.dirname
             for f in self.copy_buffer:
                 if os.path.isdir(f.path):
                     for _ in shutil_g.copytree(src=f.path,
                                                dst=os.path.join(
                                                    self.original_path,
                                                    f.basename),
                                                symlinks=True,
                                                overwrite=self.overwrite):
                         self.percent += bar_tick
                         yield
                 else:
                     for _ in shutil_g.copy2(f.path,
                                             self.original_path,
                                             symlinks=True,
                                             overwrite=self.overwrite):
                         self.percent += bar_tick
                         yield
         cwd = self.fm.get_directory(self.original_path)
         cwd.load_content()
Exemplo n.º 6
0
 def generate(self):
     from ranger.ext import shutil_generatorized as shutil_g
     if self.copy_buffer:
         # TODO: Don't calculate size when renaming (needs detection)
         bytes_per_tick = shutil_g.BLOCK_SIZE
         size = max(1, self._calculate_size(bytes_per_tick))
         bar_tick = 100.0 / (float(size) / bytes_per_tick)
         if self.do_cut:
             self.original_copy_buffer.clear()
             if len(self.copy_buffer) == 1:
                 self.description = "moving: " + self.one_file.path
             else:
                 self.description = "moving files from: " + self.one_file.dirname
             for f in self.copy_buffer:
                 for _ in shutil_g.move(src=f.path,
                         dst=self.original_path,
                         overwrite=self.overwrite):
                     self.percent += bar_tick
                     yield
         else:
             if len(self.copy_buffer) == 1:
                 self.description = "copying: " + self.one_file.path
             else:
                 self.description = "copying files from: " + self.one_file.dirname
             for f in self.copy_buffer:
                 if os.path.isdir(f.path) and not os.path.islink(f.path):
                     for _ in shutil_g.copytree(src=f.path,
                             dst=os.path.join(self.original_path, f.basename),
                             symlinks=True,
                             overwrite=self.overwrite):
                         self.percent += bar_tick
                         yield
                 else:
                     for _ in shutil_g.copy2(f.path, self.original_path,
                             symlinks=True,
                             overwrite=self.overwrite):
                         self.percent += bar_tick
                         yield
         cwd = self.fm.get_directory(self.original_path)
         cwd.load_content()
Exemplo n.º 7
0
def _shutil_gen_move(*args, **kwargs):
    import ranger.ext.shutil_generatorized as m
    return deferred(m.move(*args, **kwargs))