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
-
readable' href='/acidbong/suckless/dwm/commit/dwm.h?h=3.8&id=b5159dfd2f552696b049b95e0d368a2c33a1002a'>b5159df ^
8b59083 ^


bf35794 ^

b5159df ^
8b59083 ^
281f098 ^
8b59083 ^
b55bd70 ^


bf35794 ^


281f098 ^
8b59083 ^
b5159df ^
1076f2b
da2bbd3 ^
3399650 ^
1173723 ^
346bdea ^
438beea ^
a05beb6 ^
2e836ec ^
a05beb6 ^
9d73909 ^
0f395c1 ^
b355755 ^
1076f2b
72707c2 ^
15abade ^
bf35794 ^
7e597ae ^
1076f2b

281f098 ^


6fc8a63 ^

281f098 ^
5983c00 ^
bf35794 ^
d800ec0 ^
7d7cde0 ^
bf35794 ^
d2d394e ^
bf35794 ^
bf35794 ^
39677ec ^
439e15d ^
d2d394e ^
b4d53bf ^
281f098 ^






6092aa9 ^
d2d394e ^

281f098 ^
3399650 ^
d7e1708 ^
6b25d06 ^

281f098 ^


868159f ^
d7e1708 ^
dba2306 ^
6b25d06 ^

b9da4b0 ^
9e8b325 ^
281f098 ^



9e8b325 ^
dba2306 ^
6b25d06 ^
281f098 ^

d2d394e ^
868159f ^

29355bd ^
8b59083 ^
281f098 ^
868159f ^
281f098 ^
868159f ^
aa13727 ^

281f098 ^
5983c00 ^

281f098 ^


4b5b3d9 ^
6b25d06 ^
868159f ^


d2d394e ^
fee8df6 ^
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
164
165
166
167
168
169
170