From b951e9c453a7c4b82523c76cabbe7bdd326c6efb Mon Sep 17 00:00:00 2001 From: John Burwell Date: Sun, 23 Apr 2023 16:43:34 -0500 Subject: [PATCH] tidy up --- requirements.txt | 3 +++ rsbbs/__init__.py | 2 +- rsbbs/bbs.py | 20 +++++++++----------- rsbbs/message.py | 7 ++----- setup.py | 9 ++++++--- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/requirements.txt b/requirements.txt index bee6c14..4e9b3ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ +greenlet==2.0.2 PyYAML==6.0 +SQLAlchemy==2.0.10 +typing_extensions==4.5.0 diff --git a/rsbbs/__init__.py b/rsbbs/__init__.py index c29fc49..73a76eb 100644 --- a/rsbbs/__init__.py +++ b/rsbbs/__init__.py @@ -1 +1 @@ -__all__ = ["bbs", "message", "project_root"] \ No newline at end of file +__all__ = ["bbs", "message", "parser", "project_root"] \ No newline at end of file diff --git a/rsbbs/bbs.py b/rsbbs/bbs.py index bbcd5f2..ea70f7c 100644 --- a/rsbbs/bbs.py +++ b/rsbbs/bbs.py @@ -6,7 +6,6 @@ import yaml from sqlalchemy import create_engine, delete, select from sqlalchemy.orm import Session -from typing import * from rsbbs.message import Message, Base from rsbbs.parser import Parser @@ -18,10 +17,15 @@ class BBS(): def __init__(self, sysv_args): - self.config = self.load_config(sysv_args.config_file) self.sysv_args = sysv_args + + self.config = self.load_config(sysv_args.config_file) + self.calling_station = sysv_args.calling_station + self.engine = self.init_engine() + self.parser = self.init_parser() + logging.config.dictConfig(self.config['logging']) @property @@ -56,8 +60,7 @@ class BBS(): # Set up the BBS command parser - @property - def parser(self): + def init_parser(self): commands = [ # (name, aliases, helpmsg, function, {arg: {arg attributes}, ...}) ('bye', ['b', 'q'], 'Sign off and disconnect', self.bye, {}), @@ -93,18 +96,13 @@ class BBS(): # Database - @property - def engine(self): + def init_engine(self): engine = create_engine('sqlite:///messages.db', echo=self.sysv_args.debug) Base.metadata.create_all(engine) return engine # Input and output - - @property - def input_stream(self): - return sys.stdin def read_line(self, prompt): output = None @@ -260,7 +258,7 @@ class BBS(): self.write_output(self.config['command_prompt']) # Parse the BBS interactive commands for the rest of time - for line in self.input_stream: + for line in sys.stdin: try: args = self.parser.parse_args(line.split()) args.func(args) diff --git a/rsbbs/message.py b/rsbbs/message.py index 41ce3ae..2d12fbc 100644 --- a/rsbbs/message.py +++ b/rsbbs/message.py @@ -1,10 +1,7 @@ from datetime import datetime, timezone -from sqlalchemy import * -from sqlalchemy.orm import * -from typing import * - -# engine = create_engine('sqlite:///messages.db', echo=True) +from sqlalchemy import Boolean, DateTime, String +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column class Base(DeclarativeBase): pass diff --git a/setup.py b/setup.py index 4c5df0f..32a6a38 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( author='John Burwell', author_email='john@atatdotdot.com', - url='https://github.com/jmbwell/really-simple-bbs', + url='https://git.b-wells.us/jmbwell/rsbbs', classifiers=[ "Programming Language :: Python :: 3", @@ -31,12 +31,15 @@ setup( entry_points={ 'console_scripts': [ - 'really-simple-bbs = main:main', + 'main.py = main:main', ], }, install_requires=[ - 'PyYAML==4.2b1', + 'greenlet==2.0.2', + 'PyYAML==6.0', + 'SQLAlchemy==2.0.10', + 'typing_extensions==4.5.0', ],