about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-25 07:21:37 +0100
committerhut <hut@lavabit.com>2009-12-25 07:21:37 +0100
commitfc972ea21dc9240a4b7147cc24674cdfa2aec11b (patch)
tree28710130fc024d4a6e00614a31a3e4ac030b6a89 /ranger
parent4781d4246e24105809c26e1b93b772533e1ad61c (diff)
downloadranger-fc972ea21dc9240a4b7147cc24674cdfa2aec11b.tar.gz
improved paste-generators
Diffstat (limited to 'ranger')
-rw-r--r--ranger/actions.py49
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)
='#n225'>225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379