about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-24 19:42:57 +0100
committerhut <hut@lavabit.com>2010-01-24 19:42:57 +0100
commit7ff4bdbfe3515442db9965bc3b46cd3371013cd9 (patch)
tree2693d3d18cfad5e69d7a97992a80dcfedfb990a5 /ranger
parent331ebf78aea448611e0de237c867cad3ba9bfd32 (diff)
downloadranger-7ff4bdbfe3515442db9965bc3b46cd3371013cd9.tar.gz
runner: bugfixes + documentation
Diffstat (limited to 'ranger')
-rw-r--r--ranger/runner.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/ranger/runner.py b/ranger/runner.py
index c5d5a78c..5d450a5b 100644
--- a/ranger/runner.py
+++ b/ranger/runner.py
@@ -44,6 +44,19 @@ devnull = open(os.devnull, 'a')
 class Context(object):
 	"""
 	A context object contains data on how to run a process.
+
+	The attributes are:
+	action -- a string with a command or a list of arguments for
+		the Popen call.
+	app -- the name of the app function. ("vim" for app_vim.)
+		app is used to get an action if the user didn't specify one.
+	mode -- a number, mainly used in determining the action in app_xyz()
+	flags -- a string with flags which change the way programs are run
+	files -- a list containing files, mainly used in app_xyz
+	file -- an arbitrary file from that list (or None)
+	fm -- the filemanager instance
+	wait -- boolean, wait for the end or execute programs in parallel?
+	popen_kws -- keyword arguments which are directly passed to Popen
 	"""
 
 	def __init__(self, **keywords):
@@ -51,13 +64,15 @@ class Context(object):
 	
 	@property
 	def filepaths(self):
-		if hasattr(self, files):
+		try:
 			return [f.path for f in self.files]
-		return []
+		except:
+			return []
 
 	def __iter__(self):
 		"""Iterate over file paths"""
-		return iter(self.filepaths)
+		for item in self.filepaths:
+			yield item
 
 	def squash_flags(self):
 		"""Remove duplicates and lowercase counterparts of uppercase flags"""
@@ -106,7 +121,8 @@ class Runner(object):
 		# an Application object.
 
 		context = Context(app=app, files=files, mode=mode,
-				flags=flags, wait=wait, popen_kws=popen_kws)
+				flags=flags, wait=wait, popen_kws=popen_kws,
+				file=files and files[0] or None)
 
 		if self.apps:
 			if try_app_first and action is not None: