diff options
author | David Lyle <david.lyle@intel.com> | 2015-04-29 18:33:29 -0600 |
---|---|---|
committer | David Lyle <dklyle0@gmail.com> | 2015-08-25 11:17:35 -0600 |
commit | ab9678d4b447d757446175e85fd27185fa5831f1 (patch) | |
tree | 689388ce8e5dbc164e7f0b7272eb6cef197f0b2c | |
parent | 829cbee14e200fd127ec4f0e0f4d743102d8e9d1 (diff) | |
download | django_openstack_auth-ab9678d4b447d757446175e85fd27185fa5831f1.tar.gz |
Removing hack for python 2.6 support
Python 2.6 support was dropped with the last release, we
no longer need this code.
Change-Id: I2957864a9a4ae81c6cd2042f226140a5f7af5457
-rw-r--r-- | openstack_auth/backend.py | 3 | ||||
-rw-r--r-- | openstack_auth/utils.py | 65 |
2 files changed, 2 insertions, 66 deletions
diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py index 0e277cf..c630fb0 100644 --- a/openstack_auth/backend.py +++ b/openstack_auth/backend.py @@ -18,6 +18,7 @@ import logging import pytz from django.conf import settings +from django.utils.module_loading import import_string # noqa from django.utils.translation import ugettext_lazy as _ from keystoneclient import exceptions as keystone_exceptions @@ -47,7 +48,7 @@ class KeystoneBackend(object): ['openstack_auth.plugin.password.PasswordPlugin', 'openstack_auth.plugin.token.TokenPlugin']) - self._auth_plugins = [utils.import_string(p)() for p in plugins] + self._auth_plugins = [import_string(p)() for p in plugins] return self._auth_plugins diff --git a/openstack_auth/utils.py b/openstack_auth/utils.py index c13a84b..1998bcf 100644 --- a/openstack_auth/utils.py +++ b/openstack_auth/utils.py @@ -14,9 +14,7 @@ import datetime import functools import logging -import sys -import django from django.conf import settings from django.contrib import auth from django.contrib.auth import middleware @@ -29,7 +27,6 @@ from keystoneclient.auth import token_endpoint from keystoneclient import session from keystoneclient.v2_0 import client as client_v2 from keystoneclient.v3 import client as client_v3 -import six from six.moves.urllib import parse as urlparse @@ -317,65 +314,3 @@ def get_endpoint_region(endpoint): Keystone V2 and V3. """ return endpoint.get('region_id') or endpoint.get('region') - - -if django.VERSION < (1, 7): - try: - from importlib import import_module - except ImportError: - # NOTE(jamielennox): importlib was introduced in python 2.7. This is - # copied from the backported importlib library. See: - # http://svn.python.org/projects/python/trunk/Lib/importlib/__init__.py - - def _resolve_name(name, package, level): - """Return the absolute name of the module to be imported.""" - if not hasattr(package, 'rindex'): - raise ValueError("'package' not set to a string") - dot = len(package) - for x in xrange(level, 1, -1): - try: - dot = package.rindex('.', 0, dot) - except ValueError: - raise ValueError("attempted relative import beyond " - "top-level package") - return "%s.%s" % (package[:dot], name) - - def import_module(name, package=None): - """Import a module. - - The 'package' argument is required when performing a relative - import. It specifies the package to use as the anchor point from - which to resolve the relative import to an absolute import. - """ - if name.startswith('.'): - if not package: - raise TypeError("relative imports require the " - "'package' argument") - level = 0 - for character in name: - if character != '.': - break - level += 1 - name = _resolve_name(name[level:], package, level) - __import__(name) - return sys.modules[name] - - # NOTE(jamielennox): copied verbatim from django 1.7 - def import_string(dotted_path): - try: - module_path, class_name = dotted_path.rsplit('.', 1) - except ValueError: - msg = "%s doesn't look like a module path" % dotted_path - six.reraise(ImportError, ImportError(msg), sys.exc_info()[2]) - - module = import_module(module_path) - - try: - return getattr(module, class_name) - except AttributeError: - msg = 'Module "%s" does not define a "%s" attribute/class' % ( - dotted_path, class_name) - six.reraise(ImportError, ImportError(msg), sys.exc_info()[2]) - -else: - from django.utils.module_loading import import_string # noqa |