Deprecated django.utils.importlib
This was a shim for pre-Python 2.7 support.
This commit is contained in:
parent
ac09558760
commit
fdd7a355bf
|
@ -6,6 +6,7 @@ variable, and then from django.conf.global_settings; see the global settings fil
|
|||
a list of all possible variables.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
@ -15,7 +16,6 @@ import warnings
|
|||
from django.conf import global_settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.functional import LazyObject, empty
|
||||
from django.utils import importlib
|
||||
from django.utils.module_loading import import_by_path
|
||||
from django.utils import six
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from importlib import import_module
|
||||
|
||||
from django.core.urlresolvers import (RegexURLPattern,
|
||||
RegexURLResolver, LocaleRegexURLResolver)
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils import six
|
||||
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ def autodiscover():
|
|||
"""
|
||||
|
||||
import copy
|
||||
from importlib import import_module
|
||||
from django.conf import settings
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import module_has_submodule
|
||||
|
||||
for app in settings.INSTALLED_APPS:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from importlib import import_module
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
|
@ -13,7 +14,6 @@ from django.http import Http404
|
|||
from django.core import urlresolvers
|
||||
from django.contrib.admindocs import utils
|
||||
from django.contrib.sites.models import Site
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils._os import upath
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext as _
|
||||
|
|
|
@ -3,11 +3,11 @@ from __future__ import unicode_literals
|
|||
import base64
|
||||
import binascii
|
||||
import hashlib
|
||||
import importlib
|
||||
|
||||
from django.dispatch import receiver
|
||||
from django.conf import settings
|
||||
from django.test.signals import setting_changed
|
||||
from django.utils import importlib
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import force_bytes, force_str, force_text
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from importlib import import_module
|
||||
import warnings
|
||||
from django.conf import settings
|
||||
from django.core import urlresolvers
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.contrib.comments.forms import CommentForm
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from datetime import datetime
|
||||
from importlib import import_module
|
||||
|
||||
from django.http import HttpRequest
|
||||
from django.conf import settings
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
from django import forms, http
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.test import TestCase
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
geom_backend = getattr(settings, 'GEOMETRY_BACKEND', 'geos')
|
||||
|
||||
try:
|
||||
module = import_module('.%s' % geom_backend, 'django.contrib.gis.geometry.backend')
|
||||
module = import_module('django.contrib.gis.geometry.backend.%s' % geom_backend)
|
||||
except ImportError:
|
||||
try:
|
||||
module = import_module(geom_backend)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from importlib import import_module
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.cache import patch_vary_headers
|
||||
from django.utils.http import cookie_date
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
class SessionMiddleware(object):
|
||||
def __init__(self):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
import hashlib
|
||||
from importlib import import_module
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
|
@ -18,7 +19,6 @@ from django.core.files.storage import FileSystemStorage, get_storage_class
|
|||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.functional import LazyObject
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils._os import upath
|
||||
|
||||
from django.contrib.staticfiles.utils import check_settings, matches_patterns
|
||||
|
|
|
@ -14,6 +14,7 @@ cache class.
|
|||
|
||||
See docs/topics/cache.txt for information on the public API.
|
||||
"""
|
||||
import importlib
|
||||
try:
|
||||
from urllib.parse import parse_qsl
|
||||
except ImportError: # Python 2
|
||||
|
@ -24,7 +25,6 @@ from django.core import signals
|
|||
from django.core.cache.backends.base import (
|
||||
InvalidCacheBackendError, CacheKeyWarning, BaseCache)
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils import importlib
|
||||
from django.utils.module_loading import import_by_path
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import collections
|
||||
import imp
|
||||
from importlib import import_module
|
||||
from optparse import OptionParser, NO_DEFAULT
|
||||
import os
|
||||
import sys
|
||||
from optparse import OptionParser, NO_DEFAULT
|
||||
import imp
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.management.base import BaseCommand, CommandError, handle_default_options
|
||||
from django.core.management.color import color_style
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils import six
|
||||
|
||||
# For backwards compatibility: get_version() used to be in this module.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import sys
|
||||
from importlib import import_module
|
||||
from optparse import make_option
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -7,7 +8,6 @@ from django.core.management import call_command
|
|||
from django.core.management.base import NoArgsCommand, CommandError
|
||||
from django.core.management.color import no_style
|
||||
from django.core.management.sql import sql_flush, emit_post_sync_signal
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.six.moves import input
|
||||
from django.utils import six
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from importlib import import_module
|
||||
|
||||
from django.core.management.base import CommandError
|
||||
from django.core.management.templates import TemplateCommand
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
class Command(TemplateCommand):
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from importlib import import_module
|
||||
|
||||
from django.core.management.base import CommandError
|
||||
from django.core.management.templates import TemplateCommand
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
class Command(TemplateCommand):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from importlib import import_module
|
||||
from optparse import make_option
|
||||
import itertools
|
||||
import traceback
|
||||
|
@ -9,7 +10,6 @@ from django.core.management.color import no_style
|
|||
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal, emit_pre_sync_signal
|
||||
from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
|
|
|
@ -16,8 +16,9 @@ To add your own serializers, use the SERIALIZATION_MODULES setting::
|
|||
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils import importlib
|
||||
from django.utils import six
|
||||
from django.core.serializers.base import SerializerDoesNotExist
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ Run with the extra option "help" for a list of additional options you can
|
|||
pass to this server.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
from django.utils import importlib
|
||||
|
||||
__version__ = "0.1"
|
||||
__all__ = ["runfastcgi"]
|
||||
|
|
|
@ -8,6 +8,7 @@ a string) and returns a tuple in this format:
|
|||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from importlib import import_module
|
||||
import re
|
||||
from threading import local
|
||||
|
||||
|
@ -17,7 +18,6 @@ from django.utils.datastructures import MultiValueDict
|
|||
from django.utils.encoding import force_str, force_text, iri_to_uri
|
||||
from django.utils.functional import memoize, lazy
|
||||
from django.utils.http import urlquote
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import module_has_submodule
|
||||
from django.utils.regex_helper import normalize
|
||||
from django.utils import six
|
||||
|
|
|
@ -9,6 +9,7 @@ except ImportError:
|
|||
from django.utils.six.moves import _dummy_thread as thread
|
||||
from collections import namedtuple
|
||||
from contextlib import contextmanager
|
||||
from importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import DEFAULT_DB_ALIAS
|
||||
|
@ -17,7 +18,6 @@ from django.db.backends import util
|
|||
from django.db.transaction import TransactionManagementError
|
||||
from django.db.utils import DatabaseErrorWrapper
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils import six
|
||||
from django.utils import timezone
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
"Utilities for loading models and the modules that contain them."
|
||||
|
||||
import imp
|
||||
from importlib import import_module
|
||||
import os
|
||||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import module_has_submodule
|
||||
from django.utils._os import upath
|
||||
from django.utils import six
|
||||
|
||||
import imp
|
||||
import sys
|
||||
import os
|
||||
|
||||
__all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models',
|
||||
'load_app', 'app_cache_ready')
|
||||
|
||||
|
@ -100,7 +100,7 @@ class AppCache(object):
|
|||
self.nesting_level += 1
|
||||
app_module = import_module(app_name)
|
||||
try:
|
||||
models = import_module('.' + MODELS_MODULE_NAME, app_name)
|
||||
models = import_module('%s.%s' % (app_name, MODELS_MODULE_NAME))
|
||||
except ImportError:
|
||||
self.nesting_level -= 1
|
||||
# If the app doesn't have a models module, we can just ignore the
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from functools import wraps
|
||||
from importlib import import_module
|
||||
import os
|
||||
import pkgutil
|
||||
from threading import local
|
||||
|
@ -7,7 +8,6 @@ import warnings
|
|||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import import_by_path
|
||||
from django.utils._os import upath
|
||||
from django.utils import six
|
||||
|
@ -104,7 +104,7 @@ class DatabaseErrorWrapper(object):
|
|||
def load_backend(backend_name):
|
||||
# Look for a fully qualified database backend name
|
||||
try:
|
||||
return import_module('.base', backend_name)
|
||||
return import_module('%s.base' % backend_name)
|
||||
except ImportError as e_user:
|
||||
# The database backend wasn't found. Display a helpful error message
|
||||
# listing all possible (built-in) database backends.
|
||||
|
|
|
@ -2,12 +2,12 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
import re
|
||||
from functools import partial
|
||||
from importlib import import_module
|
||||
from inspect import getargspec
|
||||
|
||||
from django.conf import settings
|
||||
from django.template.context import (Context, RequestContext,
|
||||
ContextPopException)
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.itercompat import is_iterable
|
||||
from django.utils.text import (smart_split, unescape_string_literal,
|
||||
get_text_list)
|
||||
|
|
|
@ -3,6 +3,7 @@ Wrapper for loading templates from "templates" directories in INSTALLED_APPS
|
|||
packages.
|
||||
"""
|
||||
|
||||
from importlib import import_module
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -11,7 +12,6 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
from django.template.base import TemplateDoesNotExist
|
||||
from django.template.loader import BaseLoader
|
||||
from django.utils._os import safe_join
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils import six
|
||||
|
||||
# At compile time, cache the directories to search.
|
||||
|
|
|
@ -5,6 +5,7 @@ import os
|
|||
import re
|
||||
import mimetypes
|
||||
from copy import copy
|
||||
from importlib import import_module
|
||||
from io import BytesIO
|
||||
try:
|
||||
from urllib.parse import unquote, urlparse, urlsplit
|
||||
|
@ -25,7 +26,6 @@ from django.test import signals
|
|||
from django.utils.functional import curry
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.itercompat import is_iterable
|
||||
from django.utils import six
|
||||
from django.test.utils import ContextList
|
||||
|
|
|
@ -3,6 +3,7 @@ This module is pending deprecation as of Django 1.6 and will be removed in
|
|||
version 1.8.
|
||||
|
||||
"""
|
||||
from importlib import import_module
|
||||
import json
|
||||
import re
|
||||
import unittest as real_unittest
|
||||
|
@ -15,7 +16,6 @@ from django.test.utils import compare_xml, strip_quotes
|
|||
# django.utils.unittest is deprecated, but so is django.test.simple,
|
||||
# and the latter will be removed before the former.
|
||||
from django.utils import unittest
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import module_has_submodule
|
||||
|
||||
__all__ = ('DjangoTestSuiteRunner',)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import decimal
|
||||
import datetime
|
||||
from importlib import import_module
|
||||
import unicodedata
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils import dateformat, numberformat, datetime_safe
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.functional import lazy
|
||||
from django.utils.safestring import mark_safe
|
||||
|
@ -54,7 +54,7 @@ def iter_format_modules(lang):
|
|||
for location in format_locations:
|
||||
for loc in locales:
|
||||
try:
|
||||
yield import_module('.formats', location % loc)
|
||||
yield import_module('%s.formats' % (location % loc))
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# Taken from Python 2.7 with permission from/by the original author.
|
||||
import warnings
|
||||
import sys
|
||||
|
||||
warnings.warn("django.utils.importlib will be removed in Django 1.9.",
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
|
||||
|
||||
def _resolve_name(name, package, level):
|
||||
"""Return the absolute name of the module to be imported."""
|
||||
if not hasattr(package, 'rindex'):
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import imp
|
||||
from importlib import import_module
|
||||
import os
|
||||
import sys
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils import six
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
def import_by_path(dotted_path, error_prefix=''):
|
||||
|
|
|
@ -6,10 +6,10 @@ import os
|
|||
import re
|
||||
import sys
|
||||
import gettext as gettext_module
|
||||
from importlib import import_module
|
||||
from threading import local
|
||||
import warnings
|
||||
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import force_str, force_text
|
||||
from django.utils.functional import memoize
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import importlib
|
||||
import json
|
||||
import os
|
||||
import gettext as gettext_module
|
||||
|
@ -5,7 +6,6 @@ import gettext as gettext_module
|
|||
from django import http
|
||||
from django.conf import settings
|
||||
from django.template import Context, Template
|
||||
from django.utils import importlib
|
||||
from django.utils.translation import check_for_language, to_locale, get_language
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.formats import get_format_modules, get_format
|
||||
|
|
|
@ -412,6 +412,8 @@ these changes.
|
|||
|
||||
* ``django.utils.dictconfig`` will be removed.
|
||||
|
||||
* ``django.utils.importlib`` will be removed.
|
||||
|
||||
* ``django.utils.unittest`` will be removed.
|
||||
|
||||
* If models are organized in a package, Django will no longer look for
|
||||
|
|
|
@ -122,11 +122,12 @@ Miscellaneous
|
|||
Features deprecated in 1.7
|
||||
==========================
|
||||
|
||||
``django.utils.dictconfig``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``django.utils.dictconfig``/``django.utils.importlib``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``django.utils.dictconfig`` was a copy of :mod:`logging.config` provided for
|
||||
Python versions prior to 2.7. It has been deprecated.
|
||||
``django.utils.dictconfig`` and ``django.utils.importlib`` were copies of
|
||||
respectively :mod:`logging.config` and :mod:`importlib` provided for Python
|
||||
versions prior to 2.7. They have been deprecated.
|
||||
|
||||
``django.utils.unittest``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
import datetime
|
||||
import decimal
|
||||
from importlib import import_module
|
||||
import os
|
||||
import pickle
|
||||
from threading import local
|
||||
|
@ -17,7 +18,6 @@ from django.utils import translation
|
|||
from django.utils.formats import (get_format, date_format, time_format,
|
||||
localize, localize_input, iter_format_modules, get_format_modules,
|
||||
number_format, reset_format_cache, sanitize_separators)
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.numberformat import format as nformat
|
||||
from django.utils._os import upath
|
||||
from django.utils.safestring import mark_safe, SafeBytes, SafeString, SafeText
|
||||
|
|
|
@ -3,6 +3,7 @@ Tests for django test runner
|
|||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from importlib import import_module
|
||||
from optparse import make_option
|
||||
import sys
|
||||
import unittest
|
||||
|
@ -13,7 +14,6 @@ from django import db
|
|||
from django.test import runner, TestCase, TransactionTestCase, skipUnlessDBFeature
|
||||
from django.test.testcases import connections_support_transactions
|
||||
from django.test.utils import IgnoreAllDeprecationWarningsMixin
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from admin_scripts.tests import AdminScriptTestCase
|
||||
from .models import Person
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import imp
|
||||
from importlib import import_module
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from zipimport import zipimporter
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import import_by_path, module_has_submodule
|
||||
from django.utils._os import upath
|
||||
|
||||
|
|
Loading…
Reference in New Issue