diff options
| author | Mathieu Pillard <m@virgule.net> | 2014-05-20 00:27:54 +0200 |
|---|---|---|
| committer | Mathieu Pillard <m@virgule.net> | 2014-05-20 00:27:54 +0200 |
| commit | e747dce3d7e04fe595bbfed54f9554c2725eb757 (patch) | |
| tree | f2c2e310e48062893f8224e08364bbff043afd84 /compressor/utils/__init__.py | |
| parent | 772ecd1ef2ce021d05cbc44eb8602f7d59db2c52 (diff) | |
| parent | 804c302495bd9d043f830ed012c76183eb5a1e2d (diff) | |
| download | django-compressor-1.4.tar.gz | |
Merge branch 'release/1.4'1.4
Diffstat (limited to 'compressor/utils/__init__.py')
| -rw-r--r-- | compressor/utils/__init__.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compressor/utils/__init__.py b/compressor/utils/__init__.py index 83a1a2a..1c3479b 100644 --- a/compressor/utils/__init__.py +++ b/compressor/utils/__init__.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- +from __future__ import unicode_literals import os +from django.utils import six + from compressor.exceptions import FilterError @@ -10,15 +13,14 @@ def get_class(class_string, exception=FilterError): """ if not hasattr(class_string, '__bases__'): try: - class_string = class_string.encode('ascii') + class_string = str(class_string) mod_name, class_name = get_mod_func(class_string) - if class_name != '': - cls = getattr(__import__(mod_name, {}, {}, ['']), class_name) + if class_name: + return getattr(__import__(mod_name, {}, {}, [str('')]), class_name) except (ImportError, AttributeError): - pass - else: - return cls - raise exception('Failed to import %s' % class_string) + raise exception('Failed to import %s' % class_string) + + raise exception("Invalid class path '%s'" % class_string) def get_mod_func(callback): @@ -48,7 +50,7 @@ def find_command(cmd, paths=None, pathext=None): """ if paths is None: paths = os.environ.get('PATH', '').split(os.pathsep) - if isinstance(paths, basestring): + if isinstance(paths, six.string_types): paths = [paths] # check if there are funny path extensions for executables, e.g. Windows if pathext is None: |
