summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-23 13:32:15 +0200
committerhut <hut@lavabit.com>2010-04-23 13:33:38 +0200
commit1f2ffbb34f63ffb0440795c4a6a0b9d93b3ab84f (patch)
treed354a392bd467636c36fcc0a6e46f1bd99ec6ba1 /ranger
parentd528952a414cde9d704f736339c1dcbe18abd2ae (diff)
downloadranger-1f2ffbb34f63ffb0440795c4a6a0b9d93b3ab84f.tar.gz
main: new function "allow_access_to_confdir"
Diffstat (limited to 'ranger')
-rw-r--r--ranger/__main__.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index cbb87cc2..3ae71fc0 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -60,19 +60,27 @@ def parse_arguments():
 	return arg
 
 
-def load_settings(fm, clean):
-	if not clean:
+def allow_access_to_confdir(confdir, allow):
+	if allow:
 		try:
-			os.makedirs(ranger.arg.confdir)
+			os.makedirs(confdir)
 		except OSError as err:
 			if err.errno != 17:  # 17 means it already exists
 				print("This configuration directory could not be created:")
-				print(ranger.arg.confdir)
+				print(confdir)
 				print("To run ranger without the need for configuration")
 				print("files, use the --clean option.")
 				raise SystemExit()
+		if not confdir in sys.path:
+			sys.path[0:0] = [confdir]
+	else:
+		if sys.path[0] == confdir:
+			del sys.path[0]
 
-		sys.path[0:0] = [ranger.arg.confdir]
+
+def load_settings(fm, clean):
+	if not clean:
+		allow_access_to_confdir(ranger.arg.confdir, True)
 
 		# Load commands
 		comcont = ranger.api.commands.CommandContainer()
@@ -107,7 +115,7 @@ def load_settings(fm, clean):
 			print("Warning: the syntax for ~/.ranger/keys.py has changed.")
 			print("Your custom keys are not loaded."\
 					"  Please update your configuration.")
-		del sys.path[0]
+		allow_access_to_confdir(ranger.arg.confdir, False)
 	else:
 		comcont = ranger.api.commands.CommandContainer()
 		ranger.api.commands.alias = comcont.alias
8d1ddb445654b8d11f6f82077a9d'>^
2d54c565 ^


2d54c565 ^



aa4ffa7e ^
2d54c565 ^









a94814f0 ^

a94814f0 ^


aa4ffa7e ^
a94814f0 ^









baf46c6a ^








6af10696 ^
475dfebd ^
baf46c6a ^


aa4ffa7e ^

baf46c6a ^
aa4ffa7e ^





baf46c6a ^






dd1ee18c ^
f3fe1d34 ^
dd1ee18c ^


f3fe1d34 ^
dd1ee18c ^
6af10696 ^
475dfebd ^
f3fe1d34 ^
dd1ee18c ^
f3fe1d34 ^
aa4ffa7e ^




f3fe1d34 ^
aa4ffa7e ^


baf46c6a ^
dd1ee18c ^
f3fe1d34 ^



bafc0f25 ^



2c15aba9 ^
bafc0f25 ^


6af10696 ^
475dfebd ^
bafc0f25 ^


aa4ffa7e ^

bafc0f25 ^
aa4ffa7e ^





bafc0f25 ^





15fce2cf ^









22ab2686 ^
6af10696 ^
475dfebd ^
15fce2cf ^


aa4ffa7e ^




15fce2cf ^
aa4ffa7e ^


15fce2cf ^





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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201