From 74fe79dbf9c0ac3ceaf201b60ebfb13d2879fdfe Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 28 Jun 2021 21:13:14 -0700 Subject: [PATCH] Make importing backends easier --- amanuensis/backend/__init__.py | 9 +++++++++ amanuensis/cli/lexicon.py | 4 +--- amanuensis/cli/user.py | 2 +- amanuensis/server/__init__.py | 5 ++--- amanuensis/server/auth/__init__.py | 2 +- amanuensis/server/home/__init__.py | 3 +-- tests/backend/test_article.py | 6 +++--- tests/backend/test_character.py | 2 +- tests/backend/test_index.py | 4 ++-- tests/backend/test_lexicon.py | 2 +- tests/backend/test_membership.py | 2 +- tests/backend/test_post.py | 2 +- tests/backend/test_user.py | 2 +- tests/conftest.py | 5 +---- 14 files changed, 26 insertions(+), 24 deletions(-) diff --git a/amanuensis/backend/__init__.py b/amanuensis/backend/__init__.py index e69de29..e0c9365 100644 --- a/amanuensis/backend/__init__.py +++ b/amanuensis/backend/__init__.py @@ -0,0 +1,9 @@ +import amanuensis.backend.article as artiq +import amanuensis.backend.character as charq +import amanuensis.backend.index as indq +import amanuensis.backend.lexicon as lexiq +import amanuensis.backend.membership as memq +import amanuensis.backend.post as postq +import amanuensis.backend.user as userq + +__all__ = ["artiq", "charq", "indq", "lexiq", "memq", "postq", "userq"] diff --git a/amanuensis/cli/lexicon.py b/amanuensis/cli/lexicon.py index 4419593..0c0e3c1 100644 --- a/amanuensis/cli/lexicon.py +++ b/amanuensis/cli/lexicon.py @@ -2,9 +2,7 @@ import logging from sqlalchemy import update -import amanuensis.backend.lexicon as lexiq -import amanuensis.backend.membership as memq -import amanuensis.backend.user as userq +from amanuensis.backend import lexiq, memq, userq from amanuensis.db import DbContext, Lexicon from .helpers import add_argument diff --git a/amanuensis/cli/user.py b/amanuensis/cli/user.py index e28455c..9506e09 100644 --- a/amanuensis/cli/user.py +++ b/amanuensis/cli/user.py @@ -1,7 +1,7 @@ import logging from typing import Optional -import amanuensis.backend.user as userq +from amanuensis.backend import userq from amanuensis.db import DbContext, User from .helpers import add_argument diff --git a/amanuensis/server/__init__.py b/amanuensis/server/__init__.py index 2f73815..d14fb5e 100644 --- a/amanuensis/server/__init__.py +++ b/amanuensis/server/__init__.py @@ -4,8 +4,7 @@ import os from flask import Flask, g -import amanuensis.backend.lexicon -import amanuensis.backend.user +from amanuensis.backend import lexiq, userq from amanuensis.config import AmanuensisConfig, CommandLineConfig from amanuensis.db import DbContext import amanuensis.server.auth as auth @@ -61,7 +60,7 @@ def get_app( app.template_filter("date")(date_format) def include_backend(): - return {"db": db, "lexiq": amanuensis.backend.lexicon, "userq": amanuensis.backend.user} + return {"db": db, "lexiq": lexiq, "userq": userq} app.context_processor(include_backend) diff --git a/amanuensis/server/auth/__init__.py b/amanuensis/server/auth/__init__.py index b88466f..4cd049b 100644 --- a/amanuensis/server/auth/__init__.py +++ b/amanuensis/server/auth/__init__.py @@ -17,7 +17,7 @@ from flask_login import ( LoginManager, ) -import amanuensis.backend.user as userq +from amanuensis.backend import userq from amanuensis.db import User from .forms import LoginForm diff --git a/amanuensis/server/home/__init__.py b/amanuensis/server/home/__init__.py index c2608b3..6103e88 100644 --- a/amanuensis/server/home/__init__.py +++ b/amanuensis/server/home/__init__.py @@ -1,7 +1,6 @@ from flask import Blueprint, render_template, g -import amanuensis.backend.user as userq -import amanuensis.backend.lexicon as lexiq +from amanuensis.backend import userq, lexiq # from .forms import LexiconCreateForm diff --git a/tests/backend/test_article.py b/tests/backend/test_article.py index 7dafe02..269a898 100644 --- a/tests/backend/test_article.py +++ b/tests/backend/test_article.py @@ -1,9 +1,9 @@ import pytest import time -from amanuensis.db import DbContext -from amanuensis.db.models import Character, Lexicon, User -import amanuensis.backend.article as artiq +from amanuensis.backend import artiq +from amanuensis.db import DbContext, Character, Lexicon, User + from amanuensis.errors import ArgumentError from tests.conftest import ObjectFactory diff --git a/tests/backend/test_character.py b/tests/backend/test_character.py index dc50302..d6808f4 100644 --- a/tests/backend/test_character.py +++ b/tests/backend/test_character.py @@ -1,7 +1,7 @@ import pytest +from amanuensis.backend import charq from amanuensis.db import * -import amanuensis.backend.character as charq from amanuensis.errors import ArgumentError diff --git a/tests/backend/test_index.py b/tests/backend/test_index.py index c5a2ac7..47128d4 100644 --- a/tests/backend/test_index.py +++ b/tests/backend/test_index.py @@ -1,8 +1,8 @@ from amanuensis.db.models import IndexType import pytest -import amanuensis.backend.index as indq -from amanuensis.db import DbContext, Lexicon, User +from amanuensis.backend import indq +from amanuensis.db import DbContext, Lexicon from amanuensis.errors import ArgumentError diff --git a/tests/backend/test_lexicon.py b/tests/backend/test_lexicon.py index 3c73d9e..8cc4f28 100644 --- a/tests/backend/test_lexicon.py +++ b/tests/backend/test_lexicon.py @@ -3,7 +3,7 @@ import time import pytest -import amanuensis.backend.lexicon as lexiq +from amanuensis.backend import lexiq from amanuensis.db import DbContext, Lexicon, User from amanuensis.errors import ArgumentError from tests.conftest import ObjectFactory diff --git a/tests/backend/test_membership.py b/tests/backend/test_membership.py index d6a0637..f62d6c1 100644 --- a/tests/backend/test_membership.py +++ b/tests/backend/test_membership.py @@ -2,9 +2,9 @@ import pytest from sqlalchemy import select +from amanuensis.backend import memq from amanuensis.db import * from amanuensis.errors import ArgumentError -import amanuensis.backend.membership as memq def test_create_membership(db: DbContext, make): diff --git a/tests/backend/test_post.py b/tests/backend/test_post.py index 773b705..d66426a 100644 --- a/tests/backend/test_post.py +++ b/tests/backend/test_post.py @@ -1,7 +1,7 @@ import pytest +from amanuensis.backend import postq from amanuensis.db import DbContext -import amanuensis.backend.post as postq from amanuensis.errors import ArgumentError diff --git a/tests/backend/test_user.py b/tests/backend/test_user.py index f657a33..43af33f 100644 --- a/tests/backend/test_user.py +++ b/tests/backend/test_user.py @@ -2,7 +2,7 @@ import os import pytest -import amanuensis.backend.user as userq +from amanuensis.backend import userq from amanuensis.db import DbContext, User from amanuensis.errors import ArgumentError diff --git a/tests/conftest.py b/tests/conftest.py index ff601bb..203da40 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,10 +10,7 @@ from bs4 import BeautifulSoup from flask.testing import FlaskClient from sqlalchemy.orm.session import close_all_sessions -import amanuensis.backend.character as charq -import amanuensis.backend.lexicon as lexiq -import amanuensis.backend.membership as memq -import amanuensis.backend.user as userq +from amanuensis.backend import charq, lexiq, memq, userq from amanuensis.config import AmanuensisConfig from amanuensis.db import DbContext, User, Lexicon, Membership, Character from amanuensis.server import get_app