diff --git a/sanic/__init__.py b/sanic/__init__.py index 364ee715..8aa5958d 100644 --- a/sanic/__init__.py +++ b/sanic/__init__.py @@ -1,5 +1,5 @@ -from .app import Sanic -from .blueprints import Blueprint +from sanic.app import Sanic +from sanic.blueprints import Blueprint __version__ = '0.3.1' diff --git a/sanic/__main__.py b/sanic/__main__.py index 8653cd55..edf41f98 100644 --- a/sanic/__main__.py +++ b/sanic/__main__.py @@ -1,8 +1,8 @@ from argparse import ArgumentParser from importlib import import_module -from .log import log -from .sanic import Sanic +from sanic.log import log +from sanic.sanic import Sanic if __name__ == "__main__": parser = ArgumentParser(prog='sanic') diff --git a/sanic/app.py b/sanic/app.py index e92aab07..46bab075 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -8,17 +8,17 @@ from inspect import isawaitable, stack, getmodulename from traceback import format_exc from urllib.parse import urlencode, urlunparse -from .config import Config -from .constants import HTTP_METHODS -from .exceptions import ServerError, URLBuildError -from .handlers import ErrorHandler -from .log import log -from .response import HTTPResponse -from .router import Router -from .server import serve, serve_multiple, HttpProtocol -from .static import register as static_register -from .testing import TestClient -from .views import CompositionView +from sanic.config import Config +from sanic.constants import HTTP_METHODS +from sanic.exceptions import ServerError, URLBuildError +from sanic.handlers import ErrorHandler +from sanic.log import log +from sanic.response import HTTPResponse +from sanic.router import Router +from sanic.server import serve, serve_multiple, HttpProtocol +from sanic.static import register as static_register +from sanic.testing import TestClient +from sanic.views import CompositionView class Sanic: diff --git a/sanic/handlers.py b/sanic/handlers.py index 294695c5..af83b2b3 100644 --- a/sanic/handlers.py +++ b/sanic/handlers.py @@ -1,12 +1,17 @@ import sys from traceback import format_exc, extract_tb -from .exceptions import ContentRangeError -from .exceptions import INTERNAL_SERVER_ERROR_HTML, TRACEBACK_LINE_HTML -from .exceptions import SanicException, HeaderNotFound, InvalidRangeType -from .exceptions import TRACEBACK_STYLE, TRACEBACK_WRAPPER_HTML -from .log import log -from .response import text, html +from sanic.exceptions import ( + ContentRangeError, + HeaderNotFound, + INTERNAL_SERVER_ERROR_HTML, + InvalidRangeType, + SanicException, + TRACEBACK_LINE_HTML, + TRACEBACK_STYLE, + TRACEBACK_WRAPPER_HTML) +from sanic.log import log +from sanic.response import text, html class ErrorHandler: diff --git a/sanic/request.py b/sanic/request.py index 9ab50ce2..086d749d 100644 --- a/sanic/request.py +++ b/sanic/request.py @@ -3,10 +3,11 @@ from collections import namedtuple from http.cookies import SimpleCookie from httptools import parse_url from urllib.parse import parse_qs -from ujson import loads as json_loads -from sanic.exceptions import InvalidUsage -from .log import log +from ujson import loads as json_loads + +from sanic.exceptions import InvalidUsage +from sanic.log import log DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream" diff --git a/sanic/response.py b/sanic/response.py index d98a9988..ad263364 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -4,7 +4,7 @@ from ujson import dumps as json_dumps from aiofiles import open as open_async -from .cookies import CookieJar +from sanic.cookies import CookieJar COMMON_STATUS_CODES = { 200: b'OK', diff --git a/sanic/router.py b/sanic/router.py index 1163cce4..f172c826 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -1,8 +1,9 @@ import re from collections import defaultdict, namedtuple from functools import lru_cache -from .exceptions import NotFound, InvalidUsage -from .views import CompositionView + +from sanic.exceptions import NotFound, InvalidUsage +from sanic.views import CompositionView Route = namedtuple( 'Route', diff --git a/sanic/server.py b/sanic/server.py index 82af48ac..42e184cc 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -1,6 +1,7 @@ import asyncio import os import traceback +import warnings from functools import partial from inspect import isawaitable from multiprocessing import Process, Event @@ -9,21 +10,19 @@ from signal import SIGTERM, SIGINT from signal import signal as signal_func from socket import socket, SOL_SOCKET, SO_REUSEADDR from time import time -import warnings from httptools import HttpRequestParser from httptools.parser.errors import HttpParserError -from .exceptions import ServerError - try: import uvloop as async_loop except ImportError: async_loop = asyncio -from .log import log -from .request import Request -from .exceptions import RequestTimeout, PayloadTooLarge, InvalidUsage +from sanic.log import log +from sanic.request import Request +from sanic.exceptions import ( + RequestTimeout, PayloadTooLarge, InvalidUsage, ServerError) current_time = None diff --git a/sanic/static.py b/sanic/static.py index aa48cecc..adbdd0ea 100644 --- a/sanic/static.py +++ b/sanic/static.py @@ -6,10 +6,14 @@ from urllib.parse import unquote from aiofiles.os import stat -from .exceptions import FileNotFound, InvalidUsage, ContentRangeError -from .exceptions import HeaderNotFound -from .handlers import ContentRangeHandler -from .response import file, HTTPResponse +from sanic.exceptions import ( + ContentRangeError, + FileNotFound, + HeaderNotFound, + InvalidUsage, +) +from sanic.handlers import ContentRangeHandler +from sanic.response import file, HTTPResponse def register(app, uri, file_or_directory, pattern, diff --git a/sanic/utils.py b/sanic/utils.py index 0aa4b33c..6b97327b 100644 --- a/sanic/utils.py +++ b/sanic/utils.py @@ -1,4 +1,5 @@ import warnings + from sanic.testing import TestClient diff --git a/sanic/views.py b/sanic/views.py index b434d44a..bc29bfbc 100644 --- a/sanic/views.py +++ b/sanic/views.py @@ -1,5 +1,5 @@ -from .exceptions import InvalidUsage -from .constants import HTTP_METHODS +from sanic.exceptions import InvalidUsage +from sanic.constants import HTTP_METHODS class HTTPMethodView: