From 58e95cff0da2cba9933edb16678970bdf7289b0c Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 5 May 2016 18:42:24 -0700 Subject: [PATCH] rdv_ws: avoid magic method-name concatenation --- src/wormhole/server/rendezvous_websocket.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/wormhole/server/rendezvous_websocket.py b/src/wormhole/server/rendezvous_websocket.py index a4876f4..9667261 100644 --- a/src/wormhole/server/rendezvous_websocket.py +++ b/src/wormhole/server/rendezvous_websocket.py @@ -87,10 +87,14 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol): if not self._channel: raise Error("Must set channel first") - meth = getattr(self, "handle_"+mtype, None) - if not meth: - raise Error("Unknown type") - return meth(self._channel, msg) + if mtype == "watch": + return self.handle_watch(self._channel, msg) + if mtype == "add": + return self.handle_add(self._channel, msg) + if mtype == "deallocate": + return self.handle_deallocate(self._channel, msg) + + raise Error("Unknown type") except Error as e: self.send("error", error=e._explain, orig=msg)