summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-05 22:45:22 +0200
committerhut <hut@lavabit.com>2010-05-05 22:45:22 +0200
commitc6953a55e46aee37a854dff3be5d965b19a7341a (patch)
tree8ab0bfc30ce640e879f6d75b5dc639cf64101e4d /ranger
parentda440d3a10b7ab05e9b55968344fff2cbc45da09 (diff)
downloadranger-c6953a55e46aee37a854dff3be5d965b19a7341a.tar.gz
cleanups
Diffstat (limited to 'ranger')
-rw-r--r--ranger/__main__.py2
-rw-r--r--ranger/core/environment.py8
-rw-r--r--ranger/core/fm.py2
-rw-r--r--ranger/defaults/commands.py2
-rw-r--r--ranger/fsobject/__init__.py6
-rw-r--r--ranger/fsobject/directory.py14
-rw-r--r--ranger/fsobject/file.py8
7 files changed, 15 insertions, 27 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index 8bb0bfa1..d63ec63b 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -35,7 +35,7 @@ from ranger.core.environment import Environment
 from ranger.shared import (EnvironmentAware, FileManagerAware,
 		SettingsAware)
 from ranger.gui.defaultui import DefaultUI as UI
-from ranger.fsobject.file import File
+from ranger.fsobject import File
 
 def parse_arguments():
 	"""Parse the program arguments"""
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index a485e277..296ba108 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -19,7 +19,7 @@ import pwd
 import socket
 from os.path import abspath, normpath, join, expanduser, isdir
 
-from ranger.fsobject.directory import Directory, NoDirectoryGiven
+from ranger.fsobject import Directory
 from ranger.container import KeyBuffer, KeyManager, History
 from ranger.ext.signal_dispatcher import SignalDispatcher
 from ranger.shared import SettingsAware
@@ -179,12 +179,8 @@ class Environment(SettingsAware, SignalDispatcher):
 		path = normpath(join(self.path, expanduser(path)))
 
 		if not isdir(path):
-			return
-
-		try:
-			new_cwd = self.get_directory(path)
-		except NoDirectoryGiven:
 			return False
+		new_cwd = self.get_directory(path)
 
 		try:
 			os.chdir(path)
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 0702e472..dfad3425 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -30,7 +30,7 @@ from ranger.container import Bookmarks
 from ranger.core.runner import Runner
 from ranger import relpath_conf
 from ranger.ext.get_executables import get_executables
-from ranger.fsobject.directory import Directory
+from ranger.fsobject import Directory
 from ranger.ext.signal_dispatcher import SignalDispatcher
 from ranger import __version__
 from ranger.core.loader import Loader
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index 3fdf4ade..278fb8d5 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -412,7 +412,7 @@ class rename(Command):
 	"""
 
 	def execute(self):
-		from ranger.fsobject.file import File
+		from ranger.fsobject import File
 		line = parse(self.line)
 		if not line.rest(1):
 			return self.fm.notify('Syntax: rename <newname>', bad=True)
diff --git a/ranger/fsobject/__init__.py b/ranger/fsobject/__init__.py
index cd3944c3..5fb4b877 100644
--- a/ranger/fsobject/__init__.py
+++ b/ranger/fsobject/__init__.py
@@ -18,9 +18,7 @@ with fast access to their properties through caching"""
 
 BAD_INFO = '?'
 
-class NotLoadedYet(Exception):
-	pass
-
+# So they can be imported from other files more easily:
 from .fsobject import FileSystemObject
 from .file import File
-from .directory import Directory, NoDirectoryGiven
+from .directory import Directory
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 43af772a..ca071510 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import os
+import os.path
 from collections import deque
 from time import time
 
@@ -34,9 +34,6 @@ def sort_by_directory(path):
 	"""returns 0 if path is a directory, otherwise 1 (for sorting)"""
 	return 1 - path.is_directory
 
-class NoDirectoryGiven(Exception):
-	pass
-
 class Directory(FileSystemObject, Accumulator, SettingsAware):
 	is_directory = True
 	enterable = False
@@ -69,10 +66,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 	}
 
 	def __init__(self, path):
-		from os.path import isfile
-
-		if isfile(path):
-			raise NoDirectoryGiven()
+		assert not os.path.isfile(path), "No directory given!"
 
 		Accumulator.__init__(self)
 		FileSystemObject.__init__(self, path)
@@ -402,8 +396,8 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 
 	def __len__(self):
 		"""The number of containing files"""
-		if not self.accessible or not self.content_loaded:
-			raise ranger.fsobject.NotLoadedYet()
+		assert self.accessible
+		assert self.content_loaded
 		assert self.files is not None
 		return len(self.files)
 
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index aa44016e..4618df33 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -13,11 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-control_characters = set(chr(n) for n in set(range(0, 9)) | set(range(14,32)))
 N_FIRST_BYTES = 20
+control_characters = set(chr(n) for n in
+		set(range(0, 9)) | set(range(14, 32)))
 
-from .fsobject import FileSystemObject as SuperClass
-class File(SuperClass):
+from ranger.fsobject import FileSystemObject
+class File(FileSystemObject):
 	is_file = True
 
 	@property
@@ -37,4 +38,3 @@ class File(SuperClass):
 		if self.firstbytes and control_characters & set(self.firstbytes):
 			return True
 		return False
-
bit.com> 2009-12-25 21:55:04 +0100 committer hut <hut@lavabit.com> 2009-12-25 21:55:04 +0100 updated pydoc pages' href='/akspecs/ranger/commit/doc/ranger.defaults.apps.html?h=v1.2.0&id=f07bb12fc5c59430e995a64956b36331ce3629b9'>f07bb12f ^
4c13e1f2 ^
f07bb12f ^
34a60763 ^




f07bb12f ^
4c13e1f2 ^
f07bb12f ^
1cd06f3f ^

4c13e1f2 ^
f07bb12f ^
34a60763 ^

c776804d ^

34a60763 ^





62cd83ba ^

4c13e1f2 ^
f07bb12f ^
34a60763 ^

4c13e1f2 ^
f07bb12f ^
34a60763 ^

4c13e1f2 ^
f07bb12f ^
34a60763 ^

c776804d ^

34a60763 ^

f07bb12f ^
34a60763 ^
f07bb12f ^

4c13e1f2 ^

34a60763 ^



f07bb12f ^




34a60763 ^




f07bb12f ^





4c13e1f2 ^






c776804d ^
34a60763 ^
f07bb12f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163