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
284' href='#n284'>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