mirror of
https://github.com/openvswitch/ovs
synced 2025-09-04 16:25:17 +00:00
stream.py: un-decorator Stream.register_method
c38f8724ae
made stream.py not use class
decorator. So Stream.register need not to be decorator any more.
So simplify it.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
committed by
Ben Pfaff
parent
c38f8724ae
commit
f7b7ee9753
@@ -54,11 +54,8 @@ class Stream(object):
|
|||||||
_SOCKET_METHODS = {}
|
_SOCKET_METHODS = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def register_method(method):
|
def register_method(method, cls):
|
||||||
def _register_method(cls):
|
Stream._SOCKET_METHODS[method + ":"] = cls
|
||||||
Stream._SOCKET_METHODS[method + ":"] = cls
|
|
||||||
return cls
|
|
||||||
return _register_method
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _find_method(name):
|
def _find_method(name):
|
||||||
@@ -350,7 +347,7 @@ class UnixStream(Stream):
|
|||||||
connect_path = suffix
|
connect_path = suffix
|
||||||
return ovs.socket_util.make_unix_socket(socket.SOCK_STREAM,
|
return ovs.socket_util.make_unix_socket(socket.SOCK_STREAM,
|
||||||
True, None, connect_path)
|
True, None, connect_path)
|
||||||
UnixStream = Stream.register_method("unix")(UnixStream)
|
Stream.register_method("unix", UnixStream)
|
||||||
|
|
||||||
|
|
||||||
class TCPStream(Stream):
|
class TCPStream(Stream):
|
||||||
@@ -361,4 +358,4 @@ class TCPStream(Stream):
|
|||||||
if not error:
|
if not error:
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
return error, sock
|
return error, sock
|
||||||
TCPStream = Stream.register_method("tcp")(TCPStream)
|
Stream.register_method("tcp", TCPStream)
|
||||||
|
Reference in New Issue
Block a user