mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-09 01:27:17 +00:00
Refactor InotifyObserver
This commit is contained in:
parent
491eaf6d5e
commit
bcee486463
@ -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 = [], []
|
||||
|
Loading…
Reference in New Issue
Block a user