Cleanup imports, use more six
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
from __future__ import with_statement, unicode_literals
|
||||
import os
|
||||
import codecs
|
||||
from importlib import import_module
|
||||
from six.moves.urllib.request import url2pathname
|
||||
|
||||
import django
|
||||
from django.core.files.base import ContentFile
|
||||
try:
|
||||
from importlib import import_module
|
||||
except:
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
try:
|
||||
from urllib.request import url2pathname
|
||||
except ImportError:
|
||||
from urllib import url2pathname
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from compressor.cache import get_hexdigest, get_mtime
|
||||
from compressor.conf import settings
|
||||
@@ -23,7 +16,6 @@ from compressor.filters import CachedCompilerFilter
|
||||
from compressor.filters.css_default import CssAbsoluteFilter
|
||||
from compressor.storage import compressor_file_storage
|
||||
from compressor.signals import post_compress
|
||||
from django.template.loader import render_to_string
|
||||
from compressor.utils import get_class, get_mod_func, staticfiles
|
||||
from compressor.utils.decorators import cached_property
|
||||
|
||||
|
@@ -3,23 +3,13 @@ import hashlib
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
from importlib import import_module
|
||||
|
||||
try:
|
||||
from django.core.cache import caches
|
||||
def get_cache(name):
|
||||
return caches[name]
|
||||
except ImportError:
|
||||
from django.core.cache import get_cache
|
||||
|
||||
from django.core.cache import caches
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils.encoding import force_text, smart_bytes
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
try:
|
||||
from importlib import import_module
|
||||
except:
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from compressor.conf import settings
|
||||
from compressor.storage import default_storage
|
||||
from compressor.utils import get_mod_func
|
||||
@@ -162,4 +152,4 @@ def cache_set(key, val, refreshed=False, timeout=None):
|
||||
return cache.set(key, packed_val, real_timeout)
|
||||
|
||||
|
||||
cache = SimpleLazyObject(lambda: get_cache(settings.COMPRESS_CACHE_BACKEND))
|
||||
cache = SimpleLazyObject(lambda: caches[settings.COMPRESS_CACHE_BACKEND])
|
||||
|
@@ -3,6 +3,7 @@ import io
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
from importlib import import_module
|
||||
from platform import system
|
||||
|
||||
if system() != "Windows":
|
||||
@@ -19,11 +20,6 @@ else:
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.files.temp import NamedTemporaryFile
|
||||
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils import six
|
||||
|
||||
|
@@ -2,8 +2,10 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from collections import OrderedDict
|
||||
from fnmatch import fnmatch
|
||||
from optparse import make_option
|
||||
from importlib import import_module
|
||||
|
||||
import django
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
@@ -11,15 +13,6 @@ import django.template
|
||||
from django.template import Context
|
||||
from django.utils import six
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from django.utils.datastructures import SortedDict as OrderedDict
|
||||
|
||||
try:
|
||||
from importlib import import_module
|
||||
except:
|
||||
from django.utils.importlib import import_module
|
||||
from django.template.loader import get_template # noqa Leave this in to preload template locations
|
||||
from django.template import engines
|
||||
|
||||
|
@@ -1,9 +1,7 @@
|
||||
from importlib import import_module
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.functional import LazyObject
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
# support legacy parser module usage
|
||||
from compressor.parser.base import ParserBase # noqa
|
||||
|
@@ -6,11 +6,7 @@ import django
|
||||
|
||||
import compressor.utils.staticfiles
|
||||
|
||||
try:
|
||||
import imp
|
||||
reload = imp.reload # Python 3
|
||||
except ImportError:
|
||||
pass
|
||||
from imp import reload
|
||||
|
||||
|
||||
def get_apps_without_staticfiles(apps):
|
||||
|
Reference in New Issue
Block a user