Merge pull request #745 from jaddison/django-1.10
Fixing 1.10 compatibility issues
This commit is contained in:
commit
f49e806467
@ -4,7 +4,6 @@ import sys
|
|||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from optparse import make_option
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
import django
|
import django
|
||||||
@ -13,14 +12,12 @@ import django.template
|
|||||||
from django.template import Context
|
from django.template import Context
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.template.loader import get_template # noqa Leave this in to preload template locations
|
from django.template.loader import get_template # noqa Leave this in to preload template locations
|
||||||
from django.template.utils import InvalidTemplateEngineError
|
|
||||||
from django.template import engines
|
from django.template import engines
|
||||||
|
|
||||||
from compressor.cache import get_offline_hexdigest, write_offline_manifest
|
from compressor.cache import get_offline_hexdigest, write_offline_manifest
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.exceptions import (OfflineGenerationError, TemplateSyntaxError,
|
from compressor.exceptions import (OfflineGenerationError, TemplateSyntaxError,
|
||||||
TemplateDoesNotExist)
|
TemplateDoesNotExist)
|
||||||
from compressor.templatetags.compress import CompressorNode
|
|
||||||
from compressor.utils import get_mod_func
|
from compressor.utils import get_mod_func
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
@ -36,23 +33,23 @@ else:
|
|||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Compress content outside of the request/response cycle"
|
help = "Compress content outside of the request/response cycle"
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--extension', '-e', action='append', dest='extensions',
|
def add_arguments(self, parser):
|
||||||
help='The file extension(s) to examine (default: ".html", '
|
parser.add_argument('--extension', '-e', action='append', dest='extensions',
|
||||||
'separate multiple extensions with commas, or use -e '
|
help='The file extension(s) to examine (default: ".html", '
|
||||||
'multiple times)'),
|
'separate multiple extensions with commas, or use -e '
|
||||||
make_option('-f', '--force', default=False, action='store_true',
|
'multiple times)')
|
||||||
help="Force the generation of compressed content even if the "
|
parser.add_argument('-f', '--force', default=False, action='store_true',
|
||||||
"COMPRESS_ENABLED setting is not True.", dest='force'),
|
help="Force the generation of compressed content even if the "
|
||||||
make_option('--follow-links', default=False, action='store_true',
|
"COMPRESS_ENABLED setting is not True.", dest='force')
|
||||||
help="Follow symlinks when traversing the COMPRESS_ROOT "
|
parser.add_argument('--follow-links', default=False, action='store_true',
|
||||||
"(which defaults to STATIC_ROOT). Be aware that using this "
|
help="Follow symlinks when traversing the COMPRESS_ROOT "
|
||||||
"can lead to infinite recursion if a link points to a parent "
|
"(which defaults to STATIC_ROOT). Be aware that using this "
|
||||||
"directory of itself.", dest='follow_links'),
|
"can lead to infinite recursion if a link points to a parent "
|
||||||
make_option('--engine', default="django", action="store",
|
"directory of itself.", dest='follow_links')
|
||||||
help="Specifies the templating engine. jinja2 or django",
|
parser.add_argument('--engine', default="django", action="store",
|
||||||
dest="engine"),
|
help="Specifies the templating engine. jinja2 or django",
|
||||||
)
|
dest="engine")
|
||||||
|
|
||||||
def get_loaders(self):
|
def get_loaders(self):
|
||||||
template_source_loaders = []
|
template_source_loaders = []
|
||||||
@ -107,10 +104,11 @@ class Command(BaseCommand):
|
|||||||
verbosity = int(options.get("verbosity", 0))
|
verbosity = int(options.get("verbosity", 0))
|
||||||
if not log:
|
if not log:
|
||||||
log = StringIO()
|
log = StringIO()
|
||||||
if not settings.TEMPLATE_LOADERS:
|
if not self.get_loaders():
|
||||||
raise OfflineGenerationError("No template loaders defined. You "
|
raise OfflineGenerationError("No template loaders defined. You "
|
||||||
"must set TEMPLATE_LOADERS in your "
|
"must set TEMPLATE_LOADERS in your "
|
||||||
"settings.")
|
"settings or set 'loaders' in your "
|
||||||
|
"TEMPLATES dictionary.")
|
||||||
templates = set()
|
templates = set()
|
||||||
if engine == 'django':
|
if engine == 'django':
|
||||||
paths = set()
|
paths = set()
|
||||||
|
Loading…
Reference in New Issue
Block a user