From bcee48646346e450213e725fff7fa5dd8e3969f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 27 Jun 2019 16:36:39 +0200 Subject: [PATCH] Refactor InotifyObserver --- lib/tfw/components/inotify/inotify.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/tfw/components/inotify/inotify.py b/lib/tfw/components/inotify/inotify.py index a989f83..4f69a02 100644 --- a/lib/tfw/components/inotify/inotify.py +++ b/lib/tfw/components/inotify/inotify.py @@ -76,11 +76,6 @@ class InotifyObserver: self._reset() def _reset(self): - dispatch_event = self._dispatch_event - class TransformerEventHandler(PatternMatchingEventHandler): - def on_any_event(self, event): - dispatch_event(event) - if isinstance(self._paths, str): self._paths = [self._paths] if isinstance(self._paths, Iterable): @@ -89,10 +84,11 @@ class InotifyObserver: raise ValueError('Expected one or more string paths.') patterns = self._files+self.patterns - self.handler = TransformerEventHandler(patterns if patterns else None, self.exclude) + handler = PatternMatchingEventHandler(patterns if patterns else None, self.exclude) + handler.on_any_event = self._dispatch_event self._observer.unschedule_all() for path in self.paths: - self._observer.schedule(self.handler, path, self._recursive) + self._observer.schedule(handler, path, self._recursive) def _extract_files_from_paths(self): files, paths = [], []