[kupfer] obj: Ignore hidden files in DirectorySource's file monitor
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] obj: Ignore hidden files in DirectorySource's file monitor
- Date: Tue, 3 May 2011 14:15:25 +0000 (UTC)
commit 492ba139ec2fc15dfc7caf3f279b3d1030ae6101
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Tue May 3 16:13:07 2011 +0200
obj: Ignore hidden files in DirectorySource's file monitor
Especially the home directory is often needlessly rescanned by file
monitoring after hidden files (dotfiles) change. It's natural to ignore
file changes for files we don't show.
kupfer/obj/sources.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/obj/sources.py b/kupfer/obj/sources.py
index 7c4d3af..93d255d 100644
--- a/kupfer/obj/sources.py
+++ b/kupfer/obj/sources.py
@@ -68,15 +68,20 @@ class DirectorySource (Source, PicklingHelperMixin, FilesystemWatchMixin):
super(DirectorySource, self).__init__(name)
self.directory = dir
self.show_hidden = show_hidden
- self.unpickle_finish()
def __repr__(self):
return "%s.%s(\"%s\", show_hidden=%s)" % (self.__class__.__module__,
self.__class__.__name__, str(self.directory), self.show_hidden)
- def unpickle_finish(self):
+ def initialize(self):
self.monitor = self.monitor_directories(self.directory)
+ def finalize(self):
+ self.monitor = None
+
+ def monitor_include_file(self, gfile):
+ return self.show_hidden or not gfile.get_basename().startswith('.')
+
def get_items(self):
try:
for fname in os.listdir(self.directory):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]