Refactor InotifyObserver

This commit is contained in:
Kristóf Tóth 2019-06-27 16:36:39 +02:00
parent 491eaf6d5e
commit bcee486463

View File

@ -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 = [], []