summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-03-15 18:27:43 +0100
committerhut <hut@lavabit.com>2013-03-15 18:27:43 +0100
commit48d5bf92ce6c8fb5132c3c464c6202ecec9289f5 (patch)
tree48caee59d411fd00c3edbb1e6fff33f2a684bd46
parente124e26958ad9db38ef836a129fab09fc9b2268a (diff)
downloadranger-48d5bf92ce6c8fb5132c3c464c6202ecec9289f5.tar.gz
settings: use regexes for local settings
-rw-r--r--ranger/container/settings.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 4a68d516..2ca77d07 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -68,6 +68,7 @@ class Settings(SignalDispatcher, FileManagerAware):
     def __init__(self):
         SignalDispatcher.__init__(self)
         self.__dict__['_localsettings'] = dict()
+        self.__dict__['_localregexes'] = dict()
         self.__dict__['_settings'] = dict()
         for name in ALLOWED_SETTINGS:
             self.signal_bind('setopt.'+name,
@@ -123,10 +124,12 @@ class Settings(SignalDispatcher, FileManagerAware):
                 path = self.fm.thisdir.path
             except:
                 pass
-        if path and path in self._localsettings and \
-                name in self._localsettings[path]:
-            return self._localsettings[path][name]
-        elif name in self._settings:
+        if path:
+            for pattern, regex in self._localregexes.items():
+                if name in self._localsettings[pattern] and\
+                        regex.search(path):
+                    return self._localsettings[pattern][name]
+        if name in self._settings:
             return self._settings[name]
         else:
             type_ = self.types_of(name)[0]
@@ -183,6 +186,12 @@ class Settings(SignalDispatcher, FileManagerAware):
         value = self._sanitize(name, value)
         if path:
             if not path in self._localsettings:
+                try:
+                    regex = re.compile(path)
+                except:
+                    # Bad regular expression
+                    return
+                self._localregexes[path] = regex
                 self._localsettings[path] = dict()
             self._localsettings[path][name] = value
 
blame/shell/parse.mu?h=hlt&id=ee429152820724f3bf33de94ae14c02f71152a09'>^
a1cfadc7 ^
cb66df2e ^
0f2d0d6a ^

b89c158e ^

03178cde ^
b89c158e ^
0749772b ^
b699982f ^
2e069918 ^
1211a47e ^
b89c158e ^
0749772b ^
26a18498 ^







2e069918 ^
26a18498 ^
93f1bee0 ^



b699982f ^
93f1bee0 ^















b699982f ^
93f1bee0 ^















b699982f ^
93f1bee0 ^











2e069918 ^



b699982f ^
2e069918 ^
26a18498 ^
613b1d57 ^







0749772b ^
1a1a1671 ^

0749772b ^





1a1a1671 ^

0749772b ^


60ef3caa ^

2e069918 ^
60ef3caa ^
2e069918 ^


613b1d57 ^





60ef3caa ^

0749772b ^
0749772b ^
d4191729 ^

60ef3caa ^
2e069918 ^


613b1d57 ^






c414b962 ^
2e069918 ^
c414b962 ^

d4191729 ^


60ef3caa ^



0749772b ^


2e069918 ^
1a1a1671 ^

0749772b ^


2e069918 ^
0749772b ^

a1cfadc7 ^
0749772b ^





067fa9c7 ^
0749772b ^
3ce95116 ^
2e069918 ^
1211a47e ^

0f2d0d6a ^
a1cfadc7 ^
0f2d0d6a ^
1211a47e ^


a1cfadc7 ^
1211a47e ^
1a1a1671 ^

1211a47e ^





124be197 ^
03178cde ^
03178cde ^
1211a47e ^

31a31570 ^
6d67e1bf ^




a1cfadc7 ^
31a31570 ^
1211a47e ^
e2ab1b30 ^



a1cfadc7 ^
31a31570 ^
03178cde ^

55cde01e ^













1211a47e ^





6d67e1bf ^




fc951149 ^
1211a47e ^
1211a47e ^
e2ab1b30 ^



a1cfadc7 ^
1211a47e ^
c4f43035 ^
613b1d57 ^
0f2d0d6a ^
613b1d57 ^
































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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
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