From d4590996e06530fa13692bddcb62e917d5ddca35 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Thu, 1 Aug 2019 22:00:26 +0200 Subject: [PATCH] More stuff moved --- app.py | 32 +++++++++++++-------------- blueprints/admin.py | 8 +++---- blueprints/api.py | 20 ++++++++--------- blueprints/indieauth.py | 4 ++-- blueprints/tasks.py | 16 +++++++------- blueprints/well_known.py | 2 +- activitypub.py => core/activitypub.py | 2 +- core/gc.py | 4 ++-- core/indexes.py | 5 +++-- {utils => core}/meta.py | 0 core/migrations.py | 2 +- core/notifications.py | 14 ++++++------ core/shared.py | 8 +++---- tasks.py => core/tasks.py | 0 14 files changed, 59 insertions(+), 58 deletions(-) rename activitypub.py => core/activitypub.py (99%) rename {utils => core}/meta.py (100%) rename tasks.py => core/tasks.py (100%) diff --git a/app.py b/app.py index 2f57dac..3de6190 100644 --- a/app.py +++ b/app.py @@ -30,24 +30,13 @@ from little_boxes.webfinger import get_actor_url from little_boxes.webfinger import get_remote_follow_template from u2flib_server import u2f -import activitypub import blueprints.admin import blueprints.indieauth import blueprints.tasks import blueprints.well_known import config -from activitypub import Box -from activitypub import embed_collection -from core.shared import MY_PERSON -from core.shared import _add_answers_to_question -from core.shared import _build_thread -from core.shared import _get_ip -from core.shared import back -from core.shared import csrf -from core.shared import login_required -from core.shared import noindex -from core.shared import paginated_query -from core.shared import post_to_outbox +from core.meta import Box +from core.activitypub import embed_collection from blueprints.api import _api_required from config import ADMIN_API_KEY from config import BLACKLIST @@ -58,9 +47,20 @@ from config import KEY from config import ME from config import MEDIA_CACHE from config import VERSION -from config import MetaKey -from config import _meta -from tasks import Tasks +from core import activitypub +from core.meta import MetaKey +from core.meta import _meta +from core.shared import MY_PERSON +from core.shared import _add_answers_to_question +from core.shared import _build_thread +from core.shared import _get_ip +from core.shared import back +from core.shared import csrf +from core.shared import login_required +from core.shared import noindex +from core.shared import paginated_query +from core.shared import post_to_outbox +from core.tasks import Tasks from utils import now from utils.key import get_secret_key from utils.template_filters import filters diff --git a/blueprints/admin.py b/blueprints/admin.py index 3ed7967..9326aae 100644 --- a/blueprints/admin.py +++ b/blueprints/admin.py @@ -19,7 +19,10 @@ from passlib.hash import bcrypt from u2flib_server import u2f import config -from activitypub import Box +from core.activitypub import Box +from config import DB +from config import ID +from config import PASS from core.shared import MY_PERSON from core.shared import _build_thread from core.shared import _Response @@ -29,9 +32,6 @@ from core.shared import noindex from core.shared import p from core.shared import paginated_query from core.shared import post_to_outbox -from config import DB -from config import ID -from config import PASS from utils import now from utils.lookup import lookup diff --git a/blueprints/api.py b/blueprints/api.py index 2b33d3c..ccfa84e 100644 --- a/blueprints/api.py +++ b/blueprints/api.py @@ -23,14 +23,8 @@ from little_boxes.errors import ActivityNotFoundError from little_boxes.errors import NotFromOutboxError from werkzeug.utils import secure_filename -import activitypub import config -from activitypub import Box -from core.shared import MY_PERSON -from core.shared import _Response -from core.shared import back -from core.shared import csrf -from core.shared import post_to_outbox +from core.meta import Box from config import BASE_URL from config import DB from config import DEBUG_MODE @@ -38,10 +32,16 @@ from config import ID from config import JWT from config import MEDIA_CACHE from config import _drop_db -from tasks import Tasks +from core import activitypub +from core.meta import MetaKey +from core.meta import _meta +from core.shared import MY_PERSON +from core.shared import _Response +from core.shared import back +from core.shared import csrf +from core.shared import post_to_outbox +from core.tasks import Tasks from utils import now -from utils.meta import MetaKey -from utils.meta import _meta blueprint = flask.Blueprint("api", __name__) diff --git a/blueprints/indieauth.py b/blueprints/indieauth.py index a063387..9514ec3 100644 --- a/blueprints/indieauth.py +++ b/blueprints/indieauth.py @@ -16,10 +16,10 @@ from flask import session from flask import url_for from itsdangerous import BadSignature -from core.shared import _get_ip -from core.shared import login_required from config import DB from config import JWT +from core.shared import _get_ip +from core.shared import login_required blueprint = flask.Blueprint("indieauth", __name__) diff --git a/blueprints/tasks.py b/blueprints/tasks.py index 40a7bd6..6fdf976 100644 --- a/blueprints/tasks.py +++ b/blueprints/tasks.py @@ -13,22 +13,22 @@ from little_boxes.errors import NotAnActivityError from little_boxes.httpsig import HTTPSigAuth from requests.exceptions import HTTPError -from core import gc -import activitypub import config -from activitypub import Box +from core.activitypub import Box +from config import DB +from core import activitypub +from core import gc +from core.meta import MetaKey +from core.meta import _meta +from core.notifications import set_inbox_flags from core.shared import MY_PERSON from core.shared import _add_answers_to_question from core.shared import back from core.shared import p from core.shared import post_to_outbox -from config import DB -from core.notifications import set_inbox_flags -from tasks import Tasks +from core.tasks import Tasks from utils import now from utils import opengraph -from utils.meta import MetaKey -from utils.meta import _meta SIG_AUTH = HTTPSigAuth(config.KEY) diff --git a/blueprints/well_known.py b/blueprints/well_known.py index 7af0834..d4ec755 100644 --- a/blueprints/well_known.py +++ b/blueprints/well_known.py @@ -9,7 +9,7 @@ from flask import request from little_boxes import activitypub as ap import config -from activitypub import Box +from core.meta import Box from config import DB blueprint = flask.Blueprint("well_known", __name__) diff --git a/activitypub.py b/core/activitypub.py similarity index 99% rename from activitypub.py rename to core/activitypub.py index 547b957..4768ffd 100644 --- a/activitypub.py +++ b/core/activitypub.py @@ -28,8 +28,8 @@ from config import ID from config import ME from config import USER_AGENT from config import USERNAME +from core.meta import Box from tasks import Tasks -from utils.meta import Box logger = logging.getLogger(__name__) diff --git a/core/gc.py b/core/gc.py index 3457868..38b7fa9 100644 --- a/core/gc.py +++ b/core/gc.py @@ -8,12 +8,12 @@ from typing import List from little_boxes import activitypub as ap -import activitypub -from activitypub import Box +from core.meta import Box from config import DAYS_TO_KEEP from config import ID from config import ME from config import MEDIA_CACHE +from core import activitypub from utils.migrations import DB back = activitypub.MicroblogPubBackend() diff --git a/core/indexes.py b/core/indexes.py index e756edd..f294cac 100644 --- a/core/indexes.py +++ b/core/indexes.py @@ -1,7 +1,8 @@ import pymongo + from config import DB -from utils.meta import _meta -from utils.meta import MetaKey +from core.meta import MetaKey +from core.meta import _meta def create_indexes(): diff --git a/utils/meta.py b/core/meta.py similarity index 100% rename from utils/meta.py rename to core/meta.py diff --git a/core/migrations.py b/core/migrations.py index 7fab757..863ddf4 100644 --- a/core/migrations.py +++ b/core/migrations.py @@ -5,8 +5,8 @@ from urllib.parse import urlparse from little_boxes import activitypub as ap -import activitypub from config import ID +from core import activitypub from utils.migrations import DB from utils.migrations import Migration from utils.migrations import logger diff --git a/core/notifications.py b/core/notifications.py index e3888f6..872a009 100644 --- a/core/notifications.py +++ b/core/notifications.py @@ -8,13 +8,13 @@ from little_boxes import activitypub as ap from config import BASE_URL from config import DB -from config import MetaKey -from config import _meta -from tasks import Tasks -from utils.meta import by_actor -from utils.meta import by_type -from utils.meta import in_inbox -from utils.meta import not_undo +from core.meta import MetaKey +from core.meta import _meta +from core.meta import by_actor +from core.meta import by_type +from core.meta import in_inbox +from core.meta import not_undo +from core.tasks import Tasks _logger = logging.getLogger(__name__) diff --git a/core/shared.py b/core/shared.py index cecc724..7133cc6 100644 --- a/core/shared.py +++ b/core/shared.py @@ -19,12 +19,12 @@ from little_boxes import activitypub as ap from little_boxes.activitypub import format_datetime from poussetaches import PousseTaches -import activitypub -from activitypub import Box -from activitypub import _answer_key +from core.meta import Box +from core.activitypub import _answer_key from config import DB from config import ME -from tasks import Tasks +from core import activitypub +from core.tasks import Tasks _Response = Union[flask.Response, werkzeug.wrappers.Response, str] diff --git a/tasks.py b/core/tasks.py similarity index 100% rename from tasks.py rename to core/tasks.py