Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from logging import getLogger 

2 

3log = getLogger(__name__) 

4 

5 

6class SimpleDispatcher: 

7 prefix = "do_" 

8 

9 def __call__(self, method, params): 

10 log.debug("dispatch %s %s", method, params) 

11 mtn = self.prefix + method.replace(".", "_") 

12 if hasattr(self, mtn) and callable(getattr(self, mtn)): 

13 log.debug("found method %s", mtn) 

14 return getattr(self, mtn)(params) 

15 log.warning("method not found: %s", mtn) 

16 raise Exception("method not found: {}".format(mtn))