summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-17 22:29:26 +0200
committerhut <hut@lavabit.com>2010-05-17 22:29:26 +0200
commit4fc56903c47660d827c7bf27a30395498f72ee21 (patch)
treee896541bdd7f027b72182e9af1edea8bd08a318d
parent1337039291f72d1514fe95586c585234b66436d3 (diff)
downloadranger-4fc56903c47660d827c7bf27a30395498f72ee21.tar.gz
fsobject: moved some code from fsobject to directory
-rw-r--r--ranger/fsobject/directory.py20
-rw-r--r--ranger/fsobject/fsobject.py23
2 files changed, 22 insertions, 21 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 930ecb70..50564835 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -97,6 +97,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 		for opt in ('hidden_filter', 'show_hidden'):
 			self.settings.signal_bind('setopt.' + opt,
 				self.request_reload, weak=True)
+		self.use()
 
 	def request_resort(self):
 		self.order_outdated = True
@@ -400,6 +401,25 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 			return True
 		return False
 
+	def get_description(self):
+		return "Loading " + str(self)
+
+	def use(self):
+		"""mark the filesystem-object as used at the current time"""
+		self.last_used = time()
+
+	def is_older_than(self, seconds):
+		"""returns whether this object wasn't use()d in the last n seconds"""
+		if seconds < 0:
+			return True
+		return self.last_used + seconds < time()
+
+	def go(self):
+		"""enter the directory if the filemanager is running"""
+		if self.fm:
+			return self.fm.enter_dir(self.path)
+		return False
+
 	def empty(self):
 		"""Is the directory empty?"""
 		return self.files is None or len(self.files) == 0
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 985efb2d..963d4472 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -34,10 +34,9 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 	dirname,
 	extension,
 	infostring,
-	last_used,
 	path,
 	permissions,
-	stat) = (None,) * 11
+	stat) = (None,) * 10
 
 	(content_loaded,
 	force_load,
@@ -87,8 +86,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 		except ValueError:
 			self.extension = None
 
-		self.use()
-
 	def __repr__(self):
 		return "<{0} {1}>".format(self.__class__.__name__, self.path)
 
@@ -109,22 +106,12 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 				self._filetype = got
 		return self._filetype
 
-	def get_description(self):
-		return "Loading " + str(self)
-
 	def __str__(self):
 		"""returns a string containing the absolute path"""
 		return str(self.path)
 
 	def use(self):
-		"""mark the filesystem-object as used at the current time"""
-		self.last_used = time()
-
-	def is_older_than(self, seconds):
-		"""returns whether this object wasn't use()d in the last n seconds"""
-		if seconds < 0:
-			return True
-		return self.last_used + seconds < time()
+		"""Used in garbage-collecting.  Override in Directory"""
 
 	def set_mimetype(self):
 		"""assign attributes such as self.video according to the mimetype"""
@@ -275,12 +262,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 		self.permissions = ''.join(perms)
 		return self.permissions
 
-	def go(self):
-		"""enter the directory if the filemanager is running"""
-		if self.fm:
-			return self.fm.enter_dir(self.path)
-		return False
-
 	def load_if_outdated(self):
 		"""
 		Calls load() if the currently cached information is outdated