Skip to content

Commit

Permalink
Revert "Allow overriding or adding custom event handlers to event dis…
Browse files Browse the repository at this point in the history
…patch map (#814)"

This reverts commit be845f3.

Fixes #830.
  • Loading branch information
BoboTiG committed Aug 23, 2021
1 parent 75fe2d2 commit 354cf70
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/watchdog/events.py
Expand Up @@ -260,16 +260,6 @@ class FileSystemEventHandler:
Base file system event handler that you can override methods from.
"""

def __init__(self):
# Allow overriding or adding custom event handlers to event dispatch map.
self.event_dispatch_map = {
EVENT_TYPE_CREATED: self.on_created,
EVENT_TYPE_DELETED: self.on_deleted,
EVENT_TYPE_MODIFIED: self.on_modified,
EVENT_TYPE_MOVED: self.on_moved,
EVENT_TYPE_CLOSED: self.on_closed,
}

def dispatch(self, event):
"""Dispatches events to the appropriate methods.
Expand All @@ -279,7 +269,13 @@ def dispatch(self, event):
:class:`FileSystemEvent`
"""
self.on_any_event(event)
self.event_dispatch_map[event.event_type](event)
{
EVENT_TYPE_CREATED: self.on_created,
EVENT_TYPE_DELETED: self.on_deleted,
EVENT_TYPE_MODIFIED: self.on_modified,
EVENT_TYPE_MOVED: self.on_moved,
EVENT_TYPE_CLOSED: self.on_closed,
}[event.event_type](event)

def on_any_event(self, event):
"""Catch-all event handler.
Expand Down

0 comments on commit 354cf70

Please sign in to comment.