summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-08-05 06:19:49 +0200
committerhut <hut@lavabit.com>2012-08-05 14:36:33 +0200
commite38d42ca55285b61ed70722da92d9871c8686f88 (patch)
tree164e96ae32bae9686125f65b2fc5663dafe3a0af
parentecf47072b5bd7834d94ec90c804acb9256b8c08e (diff)
downloadranger-e38d42ca55285b61ed70722da92d9871c8686f88.tar.gz
moved fm.env.get_directory() to fm.get_directory()
-rw-r--r--ranger/core/actions.py6
-rw-r--r--ranger/core/environment.py20
-rw-r--r--ranger/core/fm.py12
-rw-r--r--ranger/fsobject/directory.py2
-rw-r--r--ranger/fsobject/fsobject.py2
-rw-r--r--ranger/gui/widgets/browserview.py2
6 files changed, 24 insertions, 20 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index ad797bec..da4c480c 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -200,7 +200,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 				tab_dir_path = self.fm.tabs[i]
 			except:
 				continue
-			tab_dir = self.fm.env.get_directory(tab_dir_path)
+			tab_dir = self.get_directory(tab_dir_path)
 			i = str(i)
 			macros[i + 'd'] = tab_dir_path
 			if tab_dir.get_selection():
@@ -226,7 +226,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 				found_current_tab = True
 		if found_current_tab and not next_tab_path:
 			next_tab_path = self.fm.tabs[first_tab]
-		next_tab = self.fm.env.get_directory(next_tab_path)
+		next_tab = self.get_directory(next_tab_path)
 
 		if next_tab:
 			macros['D'] = str(next_tab.path)
@@ -1035,7 +1035,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			return
 
 		def refresh(_):
-			cwd = self.env.get_directory(original_path)
+			cwd = self.get_directory(original_path)
 			cwd.load_content()
 
 		cwd = self.env.cwd
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index 72db5382..f04fc307 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -39,6 +39,10 @@ class EnvironmentCompatibilityWrapper(object):
 	def _set_home_path(self, obj): self.fm.home_path = obj
 	home_path = property(_get_home_path, _set_home_path)
 
+	def _get_get_directory(self): return self.fm.get_directory
+	def _set_get_directory(self, obj): self.fm.get_directory = obj
+	get_directory = property(_get_get_directory, _set_get_directory)
+
 	def _get_garbage_collect(self): return self.fm.thistab.garbage_collect
 	def _set_garbage_collect(self, obj): self.fm.thistab.garbage_collect = obj
 	garbage_collect = property(_get_garbage_collect, _set_garbage_collect)
@@ -106,16 +110,6 @@ class Environment(SettingsAware, FileManagerAware, SignalDispatcher,
 			return self.cwd.get_selection()
 		return set()
 
-	def get_directory(self, path):
-		"""Get the directory object at the given path"""
-		path = abspath(path)
-		try:
-			return self.fm.directories[path]
-		except KeyError:
-			obj = Directory(path)
-			self.fm.directories[path] = obj
-			return obj
-
 	def get_free_space(self, path):
 		stat = os.statvfs(path)
 		return stat.f_bavail * stat.f_bsize
@@ -152,7 +146,7 @@ class Environment(SettingsAware, FileManagerAware, SignalDispatcher,
 
 		if not isdir(path):
 			return False
-		new_cwd = self.get_directory(path)
+		new_cwd = self.fm.get_directory(path)
 
 		try:
 			os.chdir(path)
@@ -166,13 +160,13 @@ class Environment(SettingsAware, FileManagerAware, SignalDispatcher,
 		# build the pathway, a tuple of directory objects which lie
 		# on the path to the current directory.
 		if path == '/':
-			self.pathway = (self.get_directory('/'), )
+			self.pathway = (self.fm.get_directory('/'), )
 		else:
 			pathway = []
 			currentpath = '/'
 			for dir in path.split('/'):
 				currentpath = join(currentpath, dir)
-				pathway.append(self.get_directory(currentpath))
+				pathway.append(self.fm.get_directory(currentpath))
 			self.pathway = tuple(pathway)
 
 		self.assign_cursor_positions_for_subdirs()
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index ba2bbd51..814d16ba 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -8,7 +8,7 @@ The File Manager, putting the pieces together
 from time import time
 from collections import deque
 import mimetypes
-import os
+import os.path
 import pwd
 import socket
 import stat
@@ -180,6 +180,16 @@ class FM(Actions, SignalDispatcher):
 		"""returns the path relative to rangers library directory"""
 		return os.path.join(ranger.RANGERDIR, *paths)
 
+	def get_directory(self, path):
+		"""Get the directory object at the given path"""
+		path = os.path.abspath(path)
+		try:
+			return self.directories[path]
+		except KeyError:
+			obj = Directory(path)
+			self.directories[path] = obj
+			return obj
+
 	def garbage_collect(self, age, tabs):
 		"""Delete unused directory objects"""
 		for key in tuple(self.directories):
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index e6909fbb..70543351 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -230,7 +230,7 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 						is_a_dir = False
 					if is_a_dir:
 						try:
-							item = self.fm.env.get_directory(name)
+							item = self.fm.get_directory(name)
 							item.load_if_outdated()
 						except:
 							item = Directory(name, preload=stats,
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 75f03cfc..073da74f 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -169,7 +169,7 @@ class FileSystemObject(FileManagerAware):
 			return self._mimetype_tuple
 
 	def mark(self, boolean):
-		directory = self.env.get_directory(self.dirname)
+		directory = self.fm.get_directory(self.dirname)
 		directory.mark_item(self)
 
 	def _mark(self, boolean):
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index 36e468a0..b539ad4b 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -89,7 +89,7 @@ class BrowserView(Widget, DisplayableContainer):
 			self.need_clear = False
 		for path in self.fm.tabs.values():
 			if path is not None:
-				directory = self.env.get_directory(path)
+				directory = self.fm.get_directory(path)
 				directory.load_content_if_outdated()
 				directory.use()
 		DisplayableContainer.draw(self)