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