Minor style fixes.
This commit is contained in:
@@ -248,4 +248,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from compressor.utils import staticfiles
|
||||
from compressor.storage import CompressorFileStorage
|
||||
|
||||
|
||||
class CompressorFinder(staticfiles.finders.BaseStorageFinder):
|
||||
"""
|
||||
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 "
|
||||
"directory of itself.", dest='follow_links'),
|
||||
)
|
||||
|
||||
def get_loaders(self):
|
||||
from django.template.loader import template_source_loaders
|
||||
if template_source_loaders is None:
|
||||
@@ -113,11 +114,11 @@ class Command(NoArgsCommand):
|
||||
settings.FILE_CHARSET))
|
||||
finally:
|
||||
template_file.close()
|
||||
except IOError: # unreadable file -> ignore
|
||||
except IOError: # unreadable file -> ignore
|
||||
if verbosity > 0:
|
||||
log.write("Unreadable template at: %s\n" % template_name)
|
||||
continue
|
||||
except TemplateSyntaxError: # broken template -> ignore
|
||||
except TemplateSyntaxError: # broken template -> ignore
|
||||
if verbosity > 0:
|
||||
log.write("Invalid template at: %s\n" % template_name)
|
||||
continue
|
||||
@@ -159,7 +160,7 @@ class Command(NoArgsCommand):
|
||||
def walk_nodes(self, node):
|
||||
for node in getattr(node, "nodelist", []):
|
||||
if (isinstance(node, CompressorNode) or
|
||||
node.__class__.__name__ == "CompressorNode"): # for 1.1.X
|
||||
node.__class__.__name__ == "CompressorNode"): # for 1.1.X
|
||||
yield node
|
||||
else:
|
||||
for node in self.walk_nodes(node):
|
||||
@@ -180,7 +181,7 @@ class Command(NoArgsCommand):
|
||||
"""
|
||||
ext_list = []
|
||||
for ext in extensions:
|
||||
ext_list.extend(ext.replace(' ','').split(','))
|
||||
ext_list.extend(ext.replace(' ', '').split(','))
|
||||
for i, ext in enumerate(ext_list):
|
||||
if not ext.startswith('.'):
|
||||
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.utils import walk
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
help = "Add or remove all mtime values from the cache"
|
||||
option_list = NoArgsCommand.option_list + (
|
||||
|
@@ -7,6 +7,8 @@ from compressor.cache import cache, get_offline_cachekey
|
||||
from compressor.conf import settings
|
||||
from compressor.utils import get_class
|
||||
|
||||
register = template.Library()
|
||||
|
||||
OUTPUT_FILE = 'file'
|
||||
OUTPUT_INLINE = 'inline'
|
||||
OUTPUT_MODES = (OUTPUT_FILE, OUTPUT_INLINE)
|
||||
@@ -15,9 +17,8 @@ COMPRESSORS = {
|
||||
"js": settings.COMPRESS_JS_COMPRESSOR,
|
||||
}
|
||||
|
||||
register = template.Library()
|
||||
|
||||
class CompressorNode(template.Node):
|
||||
|
||||
def __init__(self, nodelist, kind=None, mode=OUTPUT_FILE):
|
||||
self.nodelist = nodelist
|
||||
self.kind = kind
|
||||
@@ -105,6 +106,7 @@ class CompressorNode(template.Node):
|
||||
# 5. Or don't do anything in production
|
||||
return self.nodelist.render(context)
|
||||
|
||||
|
||||
@register.tag
|
||||
def compress(parser, token):
|
||||
"""
|
||||
|
@@ -1,20 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
from shlex import split as cmd_split
|
||||
|
||||
from compressor.exceptions import FilterError
|
||||
|
||||
try:
|
||||
any = any
|
||||
|
||||
except NameError:
|
||||
|
||||
if sys.version_info < (2, 5):
|
||||
# Add any http://docs.python.org/library/functions.html?#any to Python < 2.5
|
||||
def any(seq):
|
||||
for item in seq:
|
||||
if item:
|
||||
return True
|
||||
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):
|
||||
"""
|
||||
@@ -45,20 +63,6 @@ def get_mod_func(callback):
|
||||
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):
|
||||
"""
|
||||
Returns the path extensions from environment or a default
|
||||
|
@@ -275,4 +275,4 @@ def selftest():
|
||||
print 'Test successful'
|
||||
|
||||
if __name__ == '__main__':
|
||||
selftest()
|
||||
selftest()
|
||||
|
Reference in New Issue
Block a user