(self, package, event, payload)
receiving args from common.emit_event
receiving args from common.emit_event
receiving args from common . emit_event
def dired_event_handler(self, package, event, payload):
        '''receiving args from common.emit_event'''
        def view_closed(view): self.paths.pop(view, None)

        def start_refresh(view, path):
            self.paths.update({view: [path.rstrip(os.sep)] if path else []})

        def finish_refresh(view, paths):
            if not paths:
                return

            old_paths = sorted(self.paths.get(view, []))
            paths = sorted(paths)
            if paths == old_paths:
                return

            self.paths.update({view: sorted(p for p in
                              set(old_paths + [p.rstrip(os.sep) for p in paths])
                              if os.path.exists(p))})
            self.observer.unschedule_all()
            for p in reduce(lambda i, j: i + j, self.paths.values()):
                self.observer.schedule(self.event_handler, p)

        def fold(view, path):
            p = set(self.paths.get(view, [])) - set([path.rstrip(os.sep)])
            finish_refresh(view, list(p))

        def toggle_watch_all(watch):
            '''watch is boolean or None, global setting dired_autorefresh'''
            views = self.paths.keys()
            if not watch:
                self.paths = {}
            sublime.set_timeout(lambda: refresh(views, erase_settings=(not watch)), 1)

        case = {
            'start_refresh': lambda: start_refresh(*payload),
            'finish_refresh': lambda: finish_refresh(*payload),
            'view_closed': lambda: view_closed(payload),
            'fold': lambda: fold(*payload),
            'stop_watch': lambda: view_closed(payload),
            'toggle_watch_all': lambda: toggle_watch_all(payload)
        }
        case[event]()
        emit_event(u'', self.paths, plugin=u'FileBrowserWFS')
def dired_event_handler ( self , package , event , payload ) : def view_closed ( view ) : self . paths . pop ( view , None ) def start_refresh ( view , path ) : self . paths . update ( { view : [ path . rstrip ( os . sep ) ] if path else [ ] } ) def finish_refresh ( view , paths ) : if not paths : return old_paths = sorted ( self . paths . get ( view , [ ] ) ) paths = sorted ( paths ) if paths == old_paths : return self . paths . update ( { view : sorted ( p for p in set ( old_paths + [ p . rstrip ( os . sep ) for p in paths ] ) if os . path . exists ( p ) ) } ) self . observer . unschedule_all ( ) for p in reduce ( lambda i , j : i + j , self . paths . values ( ) ) : self . observer . schedule ( self . event_handler , p ) def fold ( view , path ) : p = set ( self . paths . get ( view , [ ] ) ) - set ( [ path . rstrip ( os . sep ) ] ) finish_refresh ( view , list ( p ) ) def toggle_watch_all ( watch ) : '''watch is boolean or None, global setting dired_autorefresh''' views = self . paths . keys ( ) if not watch : self . paths = { } sublime . set_timeout ( lambda : refresh ( views , erase_settings = ( not watch ) ) , 1 ) case = { 'start_refresh' : lambda : start_refresh ( * payload ) , 'finish_refresh' : lambda : finish_refresh ( * payload ) , 'view_closed' : lambda : view_closed ( payload ) , 'fold' : lambda : fold ( * payload ) , 'stop_watch' : lambda : view_closed ( payload ) , 'toggle_watch_all' : lambda : toggle_watch_all ( payload ) } case [ event ] ( ) emit_event ( u'' , self . paths , plugin = u'FileBrowserWFS' )