mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Split data and request in different files
This commit is contained in:
parent
b4b2f74fb2
commit
e0e1290ecd
3 changed files with 21 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
||||||
"""Royalnet realated classes."""
|
"""Royalnet realated classes."""
|
||||||
from .data import Data, Request
|
from .data import Data
|
||||||
|
from .request import Request
|
||||||
from .package import Package
|
from .package import Package
|
||||||
from .royalnetlink import RoyalnetLink, NetworkError, NotConnectedError, NotIdentifiedError, ConnectionClosedError
|
from .royalnetlink import RoyalnetLink, NetworkError, NotConnectedError, NotIdentifiedError, ConnectionClosedError
|
||||||
from .royalnetserver import RoyalnetServer
|
from .royalnetserver import RoyalnetServer
|
||||||
|
|
|
@ -5,21 +5,3 @@ class Data:
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return self.__dict__
|
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
|
|
||||||
|
|
19
royalnet/network/request.py
Normal file
19
royalnet/network/request.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue