From 13e1f7650a804b579cca90dd02581521fb0feec7 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 9 Jun 2020 14:49:58 +1000 Subject: [PATCH] Rearrange source into something resembling a package --- src/{www/static/.keep => edible_elephant/__init__.py} | 0 src/{ => edible_elephant}/cli.py | 2 +- src/{ => edible_elephant}/db.py | 0 src/edible_elephant/www/__init__.py | 0 src/{ => edible_elephant}/www/serve.py | 8 +++++++- src/edible_elephant/www/static/.keep | 0 src/{ => edible_elephant}/www/templates/index.xhtml | 0 7 files changed, 8 insertions(+), 2 deletions(-) rename src/{www/static/.keep => edible_elephant/__init__.py} (100%) rename src/{ => edible_elephant}/cli.py (97%) rename src/{ => edible_elephant}/db.py (100%) create mode 100644 src/edible_elephant/www/__init__.py rename src/{ => edible_elephant}/www/serve.py (91%) create mode 100644 src/edible_elephant/www/static/.keep rename src/{ => edible_elephant}/www/templates/index.xhtml (100%) diff --git a/src/www/static/.keep b/src/edible_elephant/__init__.py similarity index 100% rename from src/www/static/.keep rename to src/edible_elephant/__init__.py diff --git a/src/cli.py b/src/edible_elephant/cli.py similarity index 97% rename from src/cli.py rename to src/edible_elephant/cli.py index 77681e5..010c714 100755 --- a/src/cli.py +++ b/src/edible_elephant/cli.py @@ -122,7 +122,7 @@ if __name__ == '__main__': args = parser.parse_args() dirname = os.path.dirname(os.path.realpath(__file__)) - dbpath = os.path.realpath(os.path.join(dirname, '..', 'db', 'data.sqlite')) + dbpath = os.path.realpath(os.path.join(dirname, '..', '..', 'db', 'data.sqlite')) db = sa.create_engine(f"sqlite:///{dbpath}") session = sa.orm.Session(db) diff --git a/src/db.py b/src/edible_elephant/db.py similarity index 100% rename from src/db.py rename to src/edible_elephant/db.py diff --git a/src/edible_elephant/www/__init__.py b/src/edible_elephant/www/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/www/serve.py b/src/edible_elephant/www/serve.py similarity index 91% rename from src/www/serve.py rename to src/edible_elephant/www/serve.py index 21aa29e..e0eccff 100755 --- a/src/www/serve.py +++ b/src/edible_elephant/www/serve.py @@ -36,7 +36,6 @@ DBSession = sqlalchemy.orm.scoped_session( def init_model(engine): DBSession.configure(bind=engine) - config.update_blueprint({ 'model': tg.util.Bunch( DBSession=DBSession, @@ -44,6 +43,13 @@ config.update_blueprint({ ) }) + +import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) + +import edible_elephant.db + application = config.make_wsgi_app() import wsgiref.simple_server diff --git a/src/edible_elephant/www/static/.keep b/src/edible_elephant/www/static/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/www/templates/index.xhtml b/src/edible_elephant/www/templates/index.xhtml similarity index 100% rename from src/www/templates/index.xhtml rename to src/edible_elephant/www/templates/index.xhtml