From e0e1290ecd778314bc2ef3b67ac642733a295847 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 22 May 2019 02:21:20 +0200 Subject: [PATCH] Split data and request in different files --- royalnet/network/__init__.py | 3 ++- royalnet/network/data.py | 18 ------------------ royalnet/network/request.py | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 royalnet/network/request.py diff --git a/royalnet/network/__init__.py b/royalnet/network/__init__.py index 68e2f3c4..3c57814b 100644 --- a/royalnet/network/__init__.py +++ b/royalnet/network/__init__.py @@ -1,5 +1,6 @@ """Royalnet realated classes.""" -from .data import Data, Request +from .data import Data +from .request import Request from .package import Package from .royalnetlink import RoyalnetLink, NetworkError, NotConnectedError, NotIdentifiedError, ConnectionClosedError from .royalnetserver import RoyalnetServer diff --git a/royalnet/network/data.py b/royalnet/network/data.py index 63895037..6f8bdf46 100644 --- a/royalnet/network/data.py +++ b/royalnet/network/data.py @@ -5,21 +5,3 @@ class Data: def to_dict(self): return self.__dict__ - - -class Request(Data): - """A Royalnet request. It contains the name of the requested handler, in addition to the data.""" - - def __init__(self, handler: str, data: dict): - super().__init__() - self.handler: str = handler - self.data: dict = data - - @staticmethod - def from_dict(d: dict): - return Request(**d) - - def __eq__(self, other): - if isinstance(other, Request): - return self.handler == other.handler and self.data == other.data - return False diff --git a/royalnet/network/request.py b/royalnet/network/request.py new file mode 100644 index 00000000..257eb21e --- /dev/null +++ b/royalnet/network/request.py @@ -0,0 +1,19 @@ +from .data import Data + + +class Request(Data): + """A Royalnet request. It contains the name of the requested handler, in addition to the data.""" + + def __init__(self, handler: str, data: dict): + super().__init__() + self.handler: str = handler + self.data: dict = data + + @staticmethod + def from_dict(d: dict): + return Request(**d) + + def __eq__(self, other): + if isinstance(other, Request): + return self.handler == other.handler and self.data == other.data + return False