From ef2c64067a28a11b7b0411e014e10a135a97fd5a Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 5 May 2009 04:18:39 +0000 Subject: [PATCH] implement buffer ignoring --HG-- branch : pmacs2 --- buffer/fs.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/buffer/fs.py b/buffer/fs.py index 5f0c8a9..22dd9c9 100644 --- a/buffer/fs.py +++ b/buffer/fs.py @@ -1,13 +1,21 @@ +import fnmatch import dirutil, os from buffer import Buffer +ignore = ['*.o', '*.lo', '*.la', '#*#', '*.rej', '*~', '.#*', '.DS_Store', + '*.pyc', '*.pyo', '.sconsign.dblite'] + class DirBuffer(Buffer): btype = 'dir' def __init__(self, path, name=None): Buffer.__init__(self) self.path = os.path.realpath(path) + self.settings['hide-dot'] = True self.settings['type-sort'] = False + self.settings['hide-glob'] = True + self.settings['ignores'] = list(ignore) + def changed(self): return False def readonly(self): @@ -36,6 +44,14 @@ class DirBuffer(Buffer): if self.settings.get('hide-dot'): if name.startswith('.') and name not in ('.', '..'): continue + if self.settings.get('hide-glob'): + skip = False + for glob in self.settings.get('ignores', []): + if fnmatch.fnmatch(name, glob): + skip = True + break + if skip: + continue path = self._make_path(name) fields = dirutil.path_fields(path, name) for i in range(0, 5):