From c47f9a7e5ab36da465bfe654583d114b786bfa1a Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sat, 25 Apr 2020 10:16:05 -0700 Subject: [PATCH] Rearrange module-local imports --- amanuensis/cli/lexicon.py | 7 ++++--- amanuensis/cli/server.py | 3 ++- amanuensis/cli/user.py | 5 +++-- amanuensis/config/__init__.py | 4 ++-- amanuensis/config/context.py | 2 +- amanuensis/config/directory.py | 3 ++- amanuensis/config/init.py | 4 ++-- amanuensis/lexicon/__init__.py | 6 +++--- amanuensis/log/__init__.py | 2 +- amanuensis/models/__init__.py | 6 +++--- amanuensis/models/factory.py | 5 +++-- amanuensis/parser/__init__.py | 8 ++++---- amanuensis/parser/analyze.py | 2 +- amanuensis/parser/parsing.py | 2 +- amanuensis/parser/render.py | 2 +- amanuensis/server/__init__.py | 10 +++++----- amanuensis/server/auth/__init__.py | 3 ++- amanuensis/user/__init__.py | 4 ++-- 18 files changed, 42 insertions(+), 36 deletions(-) diff --git a/amanuensis/cli/lexicon.py b/amanuensis/cli/lexicon.py index f8d84a0..faa8cb5 100644 --- a/amanuensis/cli/lexicon.py +++ b/amanuensis/cli/lexicon.py @@ -2,12 +2,13 @@ import logging # Module imports -from amanuensis.cli.helpers import ( - add_argument, no_argument, requires_lexicon, requires_user, alias, - config_get, config_set, CONFIG_GET_ROOT_VALUE) from amanuensis.config import RootConfigDirectoryContext from amanuensis.models import LexiconModel, UserModel +from .helpers import ( + add_argument, no_argument, requires_lexicon, requires_user, alias, + config_get, config_set, CONFIG_GET_ROOT_VALUE) + logger = logging.getLogger(__name__) # diff --git a/amanuensis/cli/server.py b/amanuensis/cli/server.py index ad8e13e..d337f4f 100644 --- a/amanuensis/cli/server.py +++ b/amanuensis/cli/server.py @@ -2,7 +2,8 @@ import logging import os from amanuensis.config import RootConfigDirectoryContext -from amanuensis.cli.helpers import ( + +from .helpers import ( add_argument, no_argument, alias, diff --git a/amanuensis/cli/user.py b/amanuensis/cli/user.py index e129e6d..0f12486 100644 --- a/amanuensis/cli/user.py +++ b/amanuensis/cli/user.py @@ -4,7 +4,9 @@ import logging # import shutil # Module imports -from amanuensis.cli.helpers import ( +from amanuensis.models import UserModel + +from .helpers import ( add_argument, no_argument, requires_user, @@ -12,7 +14,6 @@ from amanuensis.cli.helpers import ( config_get, config_set, CONFIG_GET_ROOT_VALUE) -from amanuensis.models import UserModel logger = logging.getLogger(__name__) diff --git a/amanuensis/config/__init__.py b/amanuensis/config/__init__.py index d4c7949..e202d47 100644 --- a/amanuensis/config/__init__.py +++ b/amanuensis/config/__init__.py @@ -1,6 +1,6 @@ # Module imports -from amanuensis.config.dict import AttrOrderedDict, ReadOnlyOrderedDict -from amanuensis.config.directory import ( +from .dict import AttrOrderedDict, ReadOnlyOrderedDict +from .directory import ( RootConfigDirectoryContext, UserConfigDirectoryContext, LexiconConfigDirectoryContext, diff --git a/amanuensis/config/context.py b/amanuensis/config/context.py index 235754b..19ee588 100644 --- a/amanuensis/config/context.py +++ b/amanuensis/config/context.py @@ -6,7 +6,7 @@ import fcntl import json # Application imports -from amanuensis.config.dict import AttrOrderedDict, ReadOnlyOrderedDict +from .dict import AttrOrderedDict, ReadOnlyOrderedDict class open_lock(): diff --git a/amanuensis/config/directory.py b/amanuensis/config/directory.py index 5728e18..806cde8 100644 --- a/amanuensis/config/directory.py +++ b/amanuensis/config/directory.py @@ -6,9 +6,10 @@ import os import re from typing import Iterable -from amanuensis.config.context import json_ro, json_rw from amanuensis.errors import MissingConfigError, ConfigAlreadyExistsError +from .context import json_ro, json_rw + def is_guid(s: str) -> bool: return bool(re.match(r'[0-9a-z]{32}', s.lower())) diff --git a/amanuensis/config/init.py b/amanuensis/config/init.py index dfa1e16..571b8b7 100644 --- a/amanuensis/config/init.py +++ b/amanuensis/config/init.py @@ -6,10 +6,10 @@ import os import shutil # Module imports -# from amanuensis.errors import MissingConfigError, MalformedConfigError -from amanuensis.config.context import json_ro, json_rw from amanuensis.resources import get_stream +from .context import json_ro, json_rw + def create_config_dir(config_dir, refresh=False): """ diff --git a/amanuensis/lexicon/__init__.py b/amanuensis/lexicon/__init__.py index a2e9f01..415eec7 100644 --- a/amanuensis/lexicon/__init__.py +++ b/amanuensis/lexicon/__init__.py @@ -1,9 +1,9 @@ -from amanuensis.lexicon.admin import ( +from .admin import ( valid_name, create_lexicon, load_all_lexicons) -from amanuensis.lexicon.gameloop import attempt_publish -from amanuensis.lexicon.setup import ( +from .gameloop import attempt_publish +from .setup import ( player_can_join_lexicon, add_player_to_lexicon, create_character_in_lexicon) diff --git a/amanuensis/log/__init__.py b/amanuensis/log/__init__.py index fb04046..1352ce0 100644 --- a/amanuensis/log/__init__.py +++ b/amanuensis/log/__init__.py @@ -1,4 +1,4 @@ -from amanuensis.log.setup import init_logging +from .setup import init_logging __all__ = [member.__name__ for member in [ init_logging diff --git a/amanuensis/models/__init__.py b/amanuensis/models/__init__.py index 194beb0..7ad0e74 100644 --- a/amanuensis/models/__init__.py +++ b/amanuensis/models/__init__.py @@ -1,6 +1,6 @@ -from amanuensis.models.factory import ModelFactory -from amanuensis.models.lexicon import LexiconModel -from amanuensis.models.user import UserModelBase, UserModel, AnonymousUserModel +from .factory import ModelFactory +from .lexicon import LexiconModel +from .user import UserModelBase, UserModel, AnonymousUserModel __all__ = [member.__name__ for member in [ ModelFactory, diff --git a/amanuensis/models/factory.py b/amanuensis/models/factory.py index 8d265bf..1074015 100644 --- a/amanuensis/models/factory.py +++ b/amanuensis/models/factory.py @@ -2,8 +2,9 @@ from typing import Optional from amanuensis.config import is_guid, RootConfigDirectoryContext from amanuensis.errors import ArgumentError -from amanuensis.models.user import UserModel -from amanuensis.models.lexicon import LexiconModel + +from .user import UserModel +from .lexicon import LexiconModel class ModelFactory(): diff --git a/amanuensis/parser/__init__.py b/amanuensis/parser/__init__.py index eb73e64..9aa9584 100644 --- a/amanuensis/parser/__init__.py +++ b/amanuensis/parser/__init__.py @@ -2,10 +2,10 @@ Module encapsulating all markdown parsing functionality. """ -from amanuensis.parser.analyze import FeatureCounter, GetCitations -from amanuensis.parser.helpers import titlesort, filesafe_title -from amanuensis.parser.parsing import parse_raw_markdown -from amanuensis.parser.render import PreviewHtmlRenderer, HtmlRenderer +from .analyze import FeatureCounter, GetCitations +from .helpers import titlesort, filesafe_title +from .parsing import parse_raw_markdown +from .render import PreviewHtmlRenderer, HtmlRenderer __all__ = [ FeatureCounter.__name__, diff --git a/amanuensis/parser/analyze.py b/amanuensis/parser/analyze.py index 4fa64b9..f581353 100644 --- a/amanuensis/parser/analyze.py +++ b/amanuensis/parser/analyze.py @@ -5,7 +5,7 @@ for verification against constraints. import re -from amanuensis.parser.core import RenderableVisitor +from .core import RenderableVisitor class GetCitations(RenderableVisitor): diff --git a/amanuensis/parser/parsing.py b/amanuensis/parser/parsing.py index 1e68aa1..4e0695f 100644 --- a/amanuensis/parser/parsing.py +++ b/amanuensis/parser/parsing.py @@ -6,7 +6,7 @@ Lexipython markdown. import re from typing import Sequence -from amanuensis.parser.core import ( +from .core import ( TextSpan, LineBreak, ParsedArticle, diff --git a/amanuensis/parser/render.py b/amanuensis/parser/render.py index 9cbc72c..03c2913 100644 --- a/amanuensis/parser/render.py +++ b/amanuensis/parser/render.py @@ -5,7 +5,7 @@ readable formats. from typing import Iterable -from amanuensis.parser.helpers import filesafe_title +from .helpers import filesafe_title class HtmlRenderer(): diff --git a/amanuensis/server/__init__.py b/amanuensis/server/__init__.py index 1e799a5..598798e 100644 --- a/amanuensis/server/__init__.py +++ b/amanuensis/server/__init__.py @@ -2,11 +2,11 @@ from flask import Flask from amanuensis.config import RootConfigDirectoryContext from amanuensis.models import ModelFactory -from amanuensis.server.auth import get_login_manager, bp_auth -from amanuensis.server.helpers import register_custom_filters -from amanuensis.server.home import bp_home -from amanuensis.server.lexicon import bp_lexicon -from amanuensis.server.session import bp_session +from .auth import get_login_manager, bp_auth +from .helpers import register_custom_filters +from .home import bp_home +from .lexicon import bp_lexicon +from .session import bp_session def get_app(root: RootConfigDirectoryContext) -> Flask: diff --git a/amanuensis/server/auth/__init__.py b/amanuensis/server/auth/__init__.py index 4bd860f..1fb8d93 100644 --- a/amanuensis/server/auth/__init__.py +++ b/amanuensis/server/auth/__init__.py @@ -15,9 +15,10 @@ from flask_login import ( LoginManager) from amanuensis.config import RootConfigDirectoryContext -from amanuensis.server.auth.forms import LoginForm from amanuensis.models import ModelFactory, AnonymousUserModel +from .forms import LoginForm + logger = logging.getLogger(__name__) diff --git a/amanuensis/user/__init__.py b/amanuensis/user/__init__.py index 6d8a7c7..226e97c 100644 --- a/amanuensis/user/__init__.py +++ b/amanuensis/user/__init__.py @@ -1,5 +1,5 @@ -from amanuensis.user.manage import load_all_users -from amanuensis.user.signup import ( +from .manage import load_all_users +from .signup import ( create_user, valid_username, valid_email)