xenu_nntp/lib/nntp/tiny/server.py

21 lines
553 B
Python

import enum
from nntp.tiny.db import Database
from nntp.tiny.newsgroup import Newsgroup
class ServerCapability(enum.Flag):
NONE = 0
AUTH = enum.auto()
POST = enum.auto()
class Server():
def __init__(self, db: Database):
self.db = db
self.capabilities = ServerCapability.NONE
self.newsgroups = dict()
self._init_newsgroups()
def _init_newsgroups(self):
for newsgroup in self.db.query(Newsgroup).each():
self.newsgroups[newsgroup.name.casefold()] = newsgroup