summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-24 14:42:30 +0100
committerhut <hut@lavabit.com>2009-12-24 14:42:30 +0100
commitd35bac82e6ebdbd12701f868efb104ea54c316eb (patch)
tree0eab00389332178758070d4f01bc86deaf699a29
parente92fe17a449cad78c79a905fd53ec73f8a41051c (diff)
downloadranger-d35bac82e6ebdbd12701f868efb104ea54c316eb.tar.gz
misc clean ups
-rw-r--r--ranger/fsobject/directory.py13
-rw-r--r--ranger/fsobject/loader.py28
-rw-r--r--ranger/gui/widgets/console.py7
3 files changed, 27 insertions, 21 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index f91f99d9..b83e1592 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -169,7 +169,8 @@ class Directory(SuperClass, SettingsAware):
 #		yield
 
 	def load_content(self, schedule=False):
-		"""Loads the contents of the directory. Use this sparingly since
+		"""
+		Loads the contents of the directory. Use this sparingly since
 		it takes rather long.
 		"""
 
@@ -248,7 +249,8 @@ class Directory(SuperClass, SettingsAware):
 		return self.pointed_file
 
 	def move_pointer_to_file_path(self, path):
-		"""Move the index pointer to the index of the file object
+		"""
+		Move the index pointer to the index of the file object
 		with the given path.
 		"""
 		if path is None: return
@@ -291,9 +293,7 @@ class Directory(SuperClass, SettingsAware):
 		return False
 
 	def correct_pointer(self):
-		"""make sure the pointer is in the valid range of:
-		0:len(self.files)-1 (or None if directory is empty.)
-		"""
+		"""Make sure the pointer is in the valid range"""
 
 		if self.files is None or len(self.files) == 0:
 			self.pointed_index = None
@@ -320,7 +320,8 @@ class Directory(SuperClass, SettingsAware):
 		return False
 
 	def load_content_if_outdated(self, *a, **k):
-		"""Load the contents of the directory if it's
+		"""
+		Load the contents of the directory if it's
 		outdated or not done yet
 		"""
 		if self.load_content_once(*a, **k): return True
diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py
index 483595c3..5923ff95 100644
--- a/ranger/fsobject/loader.py
+++ b/ranger/fsobject/loader.py
@@ -4,39 +4,43 @@ from ranger import log
 import math
 
 def status_generator():
+	"""Generate a rotating line which can be used as a throbber"""
 	while True:
 		yield '/'
 		yield '-'
 		yield '\\'
 		yield '|'
 
-def delayfunc(n):
-#	if n < 4:
-		return 0.05
-#	else:
-#		return 0.15
-#		return math.log(n-2) * 0.2
-
 class Loader(object):
-	seconds_of_work_time = 0.1
+	seconds_of_work_time = 0.05
+
 	def __init__(self):
 		self.queue = deque()
 		self.item = None
 		self.load_generator = None
 		self.status_generator = status_generator()
-		self.tick = 0
 		self.rotate()
 		self.old_item = None
 	
 	def rotate(self):
+		"""Rotate the throbber"""
+		# TODO: move all throbber logic to UI
 		self.status = next(self.status_generator)
 	
 	def add(self, obj):
+		"""
+		Add an object to the queue.
+		It should have a load_generator method.
+		"""
 		while obj in self.queue:
 			self.queue.remove(obj)
 		self.queue.appendleft(obj)
 
 	def work(self):
+		"""
+		Load items from the queue if there are any.
+		Stop after approximately self.seconds_of_work_time.
+		"""
 		while True:
 			# get the first item with a proper load_generator
 			try:
@@ -49,12 +53,11 @@ class Loader(object):
 				return
 
 		self.rotate()
-		self.tick += 1
 		if item != self.old_item:
-			self.tick = 0
 			self.old_item = item
 
-		end_time = time() + delayfunc(self.tick)
+		end_time = time() + self.seconds_of_work_time
+
 		try:
 			while time() < end_time:
 				next(item.load_generator)
@@ -63,4 +66,5 @@ class Loader(object):
 			self.queue.popleft()
 	
 	def has_work(self):
+		"""Is there anything to load?"""
 		return bool(self.queue)
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index ee80e639..2a4e24d9 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -267,8 +267,8 @@ class OpenConsole(Console):
 
 
 class QuickOpenConsole(Console):
-
-	"""The QuickOpenConsole allows you to open files with
+	"""
+	The QuickOpenConsole allows you to open files with
 	pre-defined programs and modes very quickly. By adding flags
 	to the command, you can specify precisely how the program is run,
 	ie. the d-flag will run it detached from the filemanager.
@@ -290,7 +290,8 @@ class QuickOpenConsole(Console):
 		Console.execute(self)
 
 	def _get_app_flags_mode(self):
-		"""extracts the application, flags and mode from
+		"""
+		Extracts the application, flags and mode from
 		a string entered into the "openwith_quick" console.
 		"""
 		# examples: