remove dependence and implmented import_string

This commit is contained in:
Jotagê Sales
2018-12-26 21:19:54 -02:00
parent 19b304b0fc
commit a33ebbaf11
5 changed files with 25 additions and 4 deletions

View File

@@ -1,10 +1,8 @@
import os
import types
import import_string
from sanic.exceptions import PyFileError
from sanic.helpers import import_string
SANIC_PREFIX = "SANIC_"

View File

@@ -1,4 +1,5 @@
"""Defines basics of HTTP standard."""
from importlib import import_module
STATUS_CODES = {
100: b"Continue",
@@ -131,3 +132,9 @@ def remove_entity_headers(headers, allowed=("content-location", "expires")):
if not is_entity_header(header) or header.lower() in allowed
}
return headers
def import_string(module_name):
module, obj = module_name.rsplit('.', 1)
module = import_module(module)
return getattr(module, obj)()