xenu_nntp/lib/nntp/tiny/remote.py
2024-12-05 18:30:52 -05:00

57 lines
1.4 KiB
Python

from nntp.tiny.response import Response
class RemoteException(Exception):
def __init__(self, response: Response):
self.response = response
def __str__(self):
return str(self.response)
class RemoteNewsgroup():
__slots__ = 'name',
def __init__(self, name: str):
self.name: str = name
def __str__(self):
return self.name
class RemoteNewsgroupDescription(RemoteNewsgroup):
__slots__ = 'name', 'description',
def __init__(self, name: str, description: str):
super().__init__(name)
self.description: str = description
def __str__(self):
return "%s %s" % (
self.name, self.description
)
class RemoteNewsgroupSummary(RemoteNewsgroup):
__slots__ = 'name', 'low', 'high', 'post',
def __init__(self, name: str, low: int, high: int, post: bool):
super().__init__(name)
self.low: int = low
self.high: int = high
self.post: bool = post
def __str__(self):
return "%s %d %d %s" % (
self.name,
self.low,
self.high,
'y' if self.post else 'n'
)
class RemoteMessageOverview():
__slots__ = (
'id', 'subject', 'sender', 'created_on', 'message_id',
'references', 'size', 'lines', 'headers'
)
def __init__(self):
self.headers = dict()