コード例 #1
0
ファイル: events.py プロジェクト: mclamb/watchdog
    def dispatch(self, event):
        """Dispatches events to the appropriate methods.

        :param event:
            The event object representing the file system event.
        :type event:
            :class:`FileSystemEvent`
        """
        if self.ignore_directories and event.is_directory:
            return

        if has_attribute(event, 'dest_path'):
            paths = [event.src_path, event.dest_path]
        else:
            paths = [event.src_path]

        if filter_paths(paths, self.patterns, self.ignore_patterns):
            self.on_any_event(event)
            _method_map = {
                EVENT_TYPE_MODIFIED: self.on_modified,
                EVENT_TYPE_MOVED: self.on_moved,
                EVENT_TYPE_CREATED: self.on_created,
                EVENT_TYPE_DELETED: self.on_deleted,
            }
            event_type = event.event_type
            _method_map[event_type](event)
コード例 #2
0
 def assert_patterns(event):
     if has_attribute(event, 'dest_path'):
         paths = [event.src_path, event.dest_path]
     else:
         paths = [event.src_path]
     filtered_paths = filter_paths(paths, patterns, ignore_patterns)
     assert_true(filtered_paths)