From 71598234b87dc0a2930a495764e1316ecec83754 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 2 Aug 2012 03:15:19 +0200 Subject: defaults.options: type of hidden_filter changed from regexp to string --- ranger/defaults/options.py | 3 +-- ranger/fsobject/directory.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index 5e30f042..c2d1fe57 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -25,8 +25,7 @@ column_ratios = (1, 3, 4) # Which files should be hidden? Toggle this by typing `zh' or # changing the setting `show_hidden' -hidden_filter = regexp( - r'^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$') +hidden_filter = r'^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$' show_hidden = False # Which script is used to generate file previews? diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 1abd6ddd..e6909fbb 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -2,6 +2,7 @@ # This software is distributed under the terms of the GNU GPL version 3. import os.path +import re from os import stat as os_stat, lstat as os_lstat from collections import deque from time import time @@ -173,8 +174,17 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware): self.mount_path = mount_path(mypath) - hidden_filter = not self.settings.show_hidden \ - and self.settings.hidden_filter + if not self.settings.show_hidden and self.settings.hidden_filter: + # COMPAT + # hidden_filter used to be a regex, not a string. If an + # old config is used, we don't need to re.compile it. + if hasattr(self.settings.hidden_filter, 'search'): + hidden_filter = self.settings.hidden_filter + else: + hidden_filter = re.compile(self.settings.hidden_filter) + else: + hidden_filter = None + filelist = os.listdir(mypath) if self._cumulative_size_calculated: -- cgit 1.4.1-2-gfad0