xenu_nntp/lib/nntp/tiny/server.py
XANTRONIX Development a34bb7a6a7 Fix typos and whatnot
2024-11-25 00:16:15 -05:00

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