Moved unneeded ImproperlyConfigured inner imports.

This commit is contained in:
Tim Graham 2017-01-16 12:48:41 -05:00 committed by GitHub
parent 1df89a60c5
commit b5511dddd6
4 changed files with 4 additions and 7 deletions

View File

@ -3,12 +3,12 @@
""" """
from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.utils.wkt import precision_wkt # NOQA from django.contrib.gis.utils.wkt import precision_wkt # NOQA
from django.core.exceptions import ImproperlyConfigured
if HAS_GDAL: if HAS_GDAL:
from django.contrib.gis.utils.ogrinfo import ogrinfo # NOQA from django.contrib.gis.utils.ogrinfo import ogrinfo # NOQA
from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect # NOQA from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect # NOQA
from django.contrib.gis.utils.srs import add_srs_entry # NOQA from django.contrib.gis.utils.srs import add_srs_entry # NOQA
from django.core.exceptions import ImproperlyConfigured
try: try:
# LayerMapping requires DJANGO_SETTINGS_MODULE to be set, # LayerMapping requires DJANGO_SETTINGS_MODULE to be set,
# so this needs to be in try/except. # so this needs to be in try/except.

View File

@ -12,6 +12,7 @@ import sys
import warnings import warnings
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import utils from django.db import utils
from django.db.backends import utils as backend_utils from django.db.backends import utils as backend_utils
from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.base import BaseDatabaseWrapper
@ -24,7 +25,6 @@ from django.utils.safestring import SafeBytes, SafeText
try: try:
import MySQLdb as Database import MySQLdb as Database
except ImportError as e: except ImportError as e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured( raise ImproperlyConfigured(
'Error loading MySQLdb module: %s.\n' 'Error loading MySQLdb module: %s.\n'
'Did you install mysqlclient or MySQL-python?' % e 'Did you install mysqlclient or MySQL-python?' % e
@ -48,7 +48,6 @@ from .validation import DatabaseValidation # isort:skip
version = Database.version_info version = Database.version_info
if (version < (1, 2, 1) or ( if (version < (1, 2, 1) or (
version[:3] == (1, 2, 1) and (len(version) < 5 or version[3] != 'final' or version[4] < 2))): version[:3] == (1, 2, 1) and (len(version) < 5 or version[3] != 'final' or version[4] < 2))):
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__) raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)

View File

@ -13,6 +13,7 @@ import sys
import warnings import warnings
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import utils from django.db import utils
from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.base import BaseDatabaseWrapper
from django.utils import six, timezone from django.utils import six, timezone
@ -28,7 +29,6 @@ def _setup_environment(environ):
try: try:
import ctypes import ctypes
except ImportError as e: except ImportError as e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("Error loading ctypes: %s; " raise ImproperlyConfigured("Error loading ctypes: %s; "
"the Oracle backend requires ctypes to " "the Oracle backend requires ctypes to "
"operate correctly under Cygwin." % e) "operate correctly under Cygwin." % e)
@ -51,7 +51,6 @@ _setup_environment([
try: try:
import cx_Oracle as Database import cx_Oracle as Database
except ImportError as e: except ImportError as e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e) raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
# Some of these import cx_Oracle, so import them after checking if it's installed. # Some of these import cx_Oracle, so import them after checking if it's installed.

View File

@ -14,6 +14,7 @@ import warnings
import pytz import pytz
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import utils from django.db import utils
from django.db.backends import utils as backend_utils from django.db.backends import utils as backend_utils
from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.base import BaseDatabaseWrapper
@ -31,7 +32,6 @@ try:
except ImportError: except ImportError:
from sqlite3 import dbapi2 as Database from sqlite3 import dbapi2 as Database
except ImportError as exc: except ImportError as exc:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc) raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
# Some of these import sqlite3, so import them after checking if it's installed. # Some of these import sqlite3, so import them after checking if it's installed.
@ -167,7 +167,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
def get_connection_params(self): def get_connection_params(self):
settings_dict = self.settings_dict settings_dict = self.settings_dict
if not settings_dict['NAME']: if not settings_dict['NAME']:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured( raise ImproperlyConfigured(
"settings.DATABASES is improperly configured. " "settings.DATABASES is improperly configured. "
"Please supply the NAME value.") "Please supply the NAME value.")