Minor style fixes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from compressor.utils import staticfiles
|
from compressor.utils import staticfiles
|
||||||
from compressor.storage import CompressorFileStorage
|
from compressor.storage import CompressorFileStorage
|
||||||
|
|
||||||
|
|
||||||
class CompressorFinder(staticfiles.finders.BaseStorageFinder):
|
class CompressorFinder(staticfiles.finders.BaseStorageFinder):
|
||||||
"""
|
"""
|
||||||
A staticfiles finder that looks in COMPRESS_ROOT
|
A staticfiles finder that looks in COMPRESS_ROOT
|
||||||
|
@@ -36,6 +36,7 @@ class Command(NoArgsCommand):
|
|||||||
"can lead to infinite recursion if a link points to a parent "
|
"can lead to infinite recursion if a link points to a parent "
|
||||||
"directory of itself.", dest='follow_links'),
|
"directory of itself.", dest='follow_links'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_loaders(self):
|
def get_loaders(self):
|
||||||
from django.template.loader import template_source_loaders
|
from django.template.loader import template_source_loaders
|
||||||
if template_source_loaders is None:
|
if template_source_loaders is None:
|
||||||
@@ -180,7 +181,7 @@ class Command(NoArgsCommand):
|
|||||||
"""
|
"""
|
||||||
ext_list = []
|
ext_list = []
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
ext_list.extend(ext.replace(' ','').split(','))
|
ext_list.extend(ext.replace(' ', '').split(','))
|
||||||
for i, ext in enumerate(ext_list):
|
for i, ext in enumerate(ext_list):
|
||||||
if not ext.startswith('.'):
|
if not ext.startswith('.'):
|
||||||
ext_list[i] = '.%s' % ext_list[i]
|
ext_list[i] = '.%s' % ext_list[i]
|
||||||
|
@@ -8,6 +8,7 @@ from compressor.cache import cache, get_mtime, get_mtime_cachekey
|
|||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.utils import walk
|
from compressor.utils import walk
|
||||||
|
|
||||||
|
|
||||||
class Command(NoArgsCommand):
|
class Command(NoArgsCommand):
|
||||||
help = "Add or remove all mtime values from the cache"
|
help = "Add or remove all mtime values from the cache"
|
||||||
option_list = NoArgsCommand.option_list + (
|
option_list = NoArgsCommand.option_list + (
|
||||||
|
@@ -7,6 +7,8 @@ from compressor.cache import cache, get_offline_cachekey
|
|||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.utils import get_class
|
from compressor.utils import get_class
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
OUTPUT_FILE = 'file'
|
OUTPUT_FILE = 'file'
|
||||||
OUTPUT_INLINE = 'inline'
|
OUTPUT_INLINE = 'inline'
|
||||||
OUTPUT_MODES = (OUTPUT_FILE, OUTPUT_INLINE)
|
OUTPUT_MODES = (OUTPUT_FILE, OUTPUT_INLINE)
|
||||||
@@ -15,9 +17,8 @@ COMPRESSORS = {
|
|||||||
"js": settings.COMPRESS_JS_COMPRESSOR,
|
"js": settings.COMPRESS_JS_COMPRESSOR,
|
||||||
}
|
}
|
||||||
|
|
||||||
register = template.Library()
|
|
||||||
|
|
||||||
class CompressorNode(template.Node):
|
class CompressorNode(template.Node):
|
||||||
|
|
||||||
def __init__(self, nodelist, kind=None, mode=OUTPUT_FILE):
|
def __init__(self, nodelist, kind=None, mode=OUTPUT_FILE):
|
||||||
self.nodelist = nodelist
|
self.nodelist = nodelist
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
@@ -105,6 +106,7 @@ class CompressorNode(template.Node):
|
|||||||
# 5. Or don't do anything in production
|
# 5. Or don't do anything in production
|
||||||
return self.nodelist.render(context)
|
return self.nodelist.render(context)
|
||||||
|
|
||||||
|
|
||||||
@register.tag
|
@register.tag
|
||||||
def compress(parser, token):
|
def compress(parser, token):
|
||||||
"""
|
"""
|
||||||
|
@@ -1,20 +1,38 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from shlex import split as cmd_split
|
from shlex import split as cmd_split
|
||||||
|
|
||||||
from compressor.exceptions import FilterError
|
from compressor.exceptions import FilterError
|
||||||
|
|
||||||
try:
|
if sys.version_info < (2, 5):
|
||||||
any = any
|
# Add any http://docs.python.org/library/functions.html?#any to Python < 2.5
|
||||||
|
|
||||||
except NameError:
|
|
||||||
|
|
||||||
def any(seq):
|
def any(seq):
|
||||||
for item in seq:
|
for item in seq:
|
||||||
if item:
|
if item:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
else:
|
||||||
|
any = any
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info < (2, 6):
|
||||||
|
def walk(root, topdown=True, onerror=None, followlinks=False):
|
||||||
|
"""
|
||||||
|
A version of os.walk that can follow symlinks for Python < 2.6
|
||||||
|
"""
|
||||||
|
for dirpath, dirnames, filenames in os.walk(root, topdown, onerror):
|
||||||
|
yield (dirpath, dirnames, filenames)
|
||||||
|
if followlinks:
|
||||||
|
for d in dirnames:
|
||||||
|
p = os.path.join(dirpath, d)
|
||||||
|
if os.path.islink(p):
|
||||||
|
for link_dirpath, link_dirnames, link_filenames in walk(p):
|
||||||
|
yield (link_dirpath, link_dirnames, link_filenames)
|
||||||
|
else:
|
||||||
|
from os import walk
|
||||||
|
|
||||||
|
|
||||||
def get_class(class_string, exception=FilterError):
|
def get_class(class_string, exception=FilterError):
|
||||||
"""
|
"""
|
||||||
@@ -45,20 +63,6 @@ def get_mod_func(callback):
|
|||||||
return callback[:dot], callback[dot + 1:]
|
return callback[:dot], callback[dot + 1:]
|
||||||
|
|
||||||
|
|
||||||
def walk(root, topdown=True, onerror=None, followlinks=False):
|
|
||||||
"""
|
|
||||||
A version of os.walk that can follow symlinks for Python < 2.6
|
|
||||||
"""
|
|
||||||
for dirpath, dirnames, filenames in os.walk(root, topdown, onerror):
|
|
||||||
yield (dirpath, dirnames, filenames)
|
|
||||||
if followlinks:
|
|
||||||
for d in dirnames:
|
|
||||||
p = os.path.join(dirpath, d)
|
|
||||||
if os.path.islink(p):
|
|
||||||
for link_dirpath, link_dirnames, link_filenames in walk(p):
|
|
||||||
yield (link_dirpath, link_dirnames, link_filenames)
|
|
||||||
|
|
||||||
|
|
||||||
def get_pathext(default_pathext=None):
|
def get_pathext(default_pathext=None):
|
||||||
"""
|
"""
|
||||||
Returns the path extensions from environment or a default
|
Returns the path extensions from environment or a default
|
||||||
|
Reference in New Issue
Block a user