Various PEP8 and pyflakes related fixes.
This commit is contained in:
@@ -4,7 +4,6 @@ import codecs
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.core.files.storage import get_storage_class
|
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.encoding import smart_unicode
|
from django.utils.encoding import smart_unicode
|
||||||
|
@@ -64,6 +64,7 @@ def get_offline_manifest_filename():
|
|||||||
|
|
||||||
_offline_manifest = None
|
_offline_manifest = None
|
||||||
|
|
||||||
|
|
||||||
def get_offline_manifest():
|
def get_offline_manifest():
|
||||||
global _offline_manifest
|
global _offline_manifest
|
||||||
if _offline_manifest is None:
|
if _offline_manifest is None:
|
||||||
|
@@ -4,6 +4,7 @@ class CompressorError(Exception):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UncompressableFileError(Exception):
|
class UncompressableFileError(Exception):
|
||||||
"""
|
"""
|
||||||
This exception is raised when a file cannot be compressed
|
This exception is raised when a file cannot be compressed
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
from compressor.filters.base import (FilterBase, CallbackOutputFilter,
|
from compressor.filters.base import (FilterBase, CallbackOutputFilter,
|
||||||
CompilerFilter, FilterError)
|
CompilerFilter, FilterError) # noqa
|
||||||
|
@@ -2,7 +2,7 @@ from __future__ import absolute_import
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.files.temp import NamedTemporaryFile
|
from django.core.files.temp import NamedTemporaryFile
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
|
@@ -2,8 +2,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import posixpath
|
import posixpath
|
||||||
|
|
||||||
from compressor.cache import (get_hexdigest, get_hashed_mtime,
|
from compressor.cache import get_hashed_mtime, get_hashed_content
|
||||||
get_hashed_content)
|
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.filters import FilterBase, FilterError
|
from compressor.filters import FilterBase, FilterError
|
||||||
from compressor.utils import staticfiles
|
from compressor.utils import staticfiles
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
from compressor.filters import CallbackOutputFilter
|
from compressor.filters import CallbackOutputFilter
|
||||||
|
|
||||||
|
|
||||||
class CSSMinFilter(CallbackOutputFilter):
|
class CSSMinFilter(CallbackOutputFilter):
|
||||||
"""
|
"""
|
||||||
A filter that utilizes Zachary Voase's Python port of
|
A filter that utilizes Zachary Voase's Python port of
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
try:
|
try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO # noqa
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from compressor.filters import CallbackOutputFilter
|
from compressor.filters import CallbackOutputFilter
|
||||||
from compressor.filters.jsmin.slimit import SlimItFilter
|
from compressor.filters.jsmin.slimit import SlimItFilter # noqa
|
||||||
|
|
||||||
|
|
||||||
class rJSMinFilter(CallbackOutputFilter):
|
class rJSMinFilter(CallbackOutputFilter):
|
||||||
callback = "compressor.filters.jsmin.rjsmin.jsmin"
|
callback = "compressor.filters.jsmin.rjsmin.jsmin"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from compressor.filters import CallbackOutputFilter
|
from compressor.filters import CallbackOutputFilter
|
||||||
|
|
||||||
|
|
||||||
class SlimItFilter(CallbackOutputFilter):
|
class SlimItFilter(CallbackOutputFilter):
|
||||||
dependencies = ["slimit"]
|
dependencies = ["slimit"]
|
||||||
callback = "slimit.minify"
|
callback = "slimit.minify"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from compressor.filters import FilterBase, FilterError
|
from compressor.filters import FilterBase
|
||||||
|
|
||||||
|
|
||||||
class TemplateFilter(FilterBase):
|
class TemplateFilter(FilterBase):
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.base import Compressor, SOURCE_HUNK, SOURCE_FILE
|
from compressor.base import Compressor, SOURCE_HUNK, SOURCE_FILE
|
||||||
from compressor.exceptions import UncompressableFileError
|
|
||||||
|
|
||||||
|
|
||||||
class JsCompressor(Compressor):
|
class JsCompressor(Compressor):
|
||||||
|
@@ -7,14 +7,14 @@ from optparse import make_option
|
|||||||
try:
|
try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO # noqa
|
||||||
|
|
||||||
from django.core.management.base import NoArgsCommand, CommandError
|
from django.core.management.base import NoArgsCommand, CommandError
|
||||||
from django.template import (Context, Template,
|
from django.template import (Context, Template,
|
||||||
TemplateDoesNotExist, TemplateSyntaxError)
|
TemplateDoesNotExist, TemplateSyntaxError)
|
||||||
from django.utils.datastructures import SortedDict
|
from django.utils.datastructures import SortedDict
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
from django.template.loader import get_template # 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.defaulttags import IfNode
|
from django.template.defaulttags import IfNode
|
||||||
from django.template.loader_tags import (ExtendsNode, BlockNode,
|
from django.template.loader_tags import (ExtendsNode, BlockNode,
|
||||||
BLOCK_CONTEXT_KEY)
|
BLOCK_CONTEXT_KEY)
|
||||||
@@ -22,7 +22,7 @@ from django.template.loader_tags import (ExtendsNode, BlockNode,
|
|||||||
try:
|
try:
|
||||||
from django.template.loaders.cached import Loader as CachedLoader
|
from django.template.loaders.cached import Loader as CachedLoader
|
||||||
except ImportError:
|
except ImportError:
|
||||||
CachedLoader = None
|
CachedLoader = None # noqa
|
||||||
|
|
||||||
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
|
||||||
@@ -30,6 +30,7 @@ from compressor.exceptions import OfflineGenerationError
|
|||||||
from compressor.templatetags.compress import CompressorNode
|
from compressor.templatetags.compress import CompressorNode
|
||||||
from compressor.utils import walk, any
|
from compressor.utils import walk, any
|
||||||
|
|
||||||
|
|
||||||
def patched_render(self, context):
|
def patched_render(self, context):
|
||||||
# 'Fake' _render method that just returns the context instead of
|
# 'Fake' _render method that just returns the context instead of
|
||||||
# rendering. It also checks whether the first node is an extend node or
|
# rendering. It also checks whether the first node is an extend node or
|
||||||
@@ -38,6 +39,7 @@ def patched_render(self, context):
|
|||||||
self._render_firstnode(context)
|
self._render_firstnode(context)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def patched_render_firstnode(self, context):
|
def patched_render_firstnode(self, context):
|
||||||
# If this template has a ExtendsNode, we want to find out what
|
# If this template has a ExtendsNode, we want to find out what
|
||||||
# should be put in render_context to make the {% block ... %}
|
# should be put in render_context to make the {% block ... %}
|
||||||
@@ -76,6 +78,7 @@ def patched_render_firstnode(self, context):
|
|||||||
return None
|
return None
|
||||||
return extra_context
|
return extra_context
|
||||||
|
|
||||||
|
|
||||||
def patched_get_parent(self, context):
|
def patched_get_parent(self, context):
|
||||||
# Patch template returned by extendsnode's get_parent to make sure their
|
# Patch template returned by extendsnode's get_parent to make sure their
|
||||||
# _render method is just returning the context instead of actually
|
# _render method is just returning the context instead of actually
|
||||||
@@ -116,7 +119,7 @@ class Command(NoArgsCommand):
|
|||||||
find_template as finder_func)
|
find_template as finder_func)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from django.template.loader import (
|
from django.template.loader import (
|
||||||
find_template_source as finder_func)
|
find_template_source as finder_func) # noqa
|
||||||
try:
|
try:
|
||||||
# Force django to calculate template_source_loaders from
|
# Force django to calculate template_source_loaders from
|
||||||
# TEMPLATE_LOADERS settings, by asking to find a dummy template
|
# TEMPLATE_LOADERS settings, by asking to find a dummy template
|
||||||
|
@@ -1 +1 @@
|
|||||||
from compressor.conf import CompressorConf
|
from compressor.conf import CompressorConf # noqa
|
||||||
|
@@ -27,7 +27,7 @@ class LxmlParser(ParserBase):
|
|||||||
content = '<root>%s</root>' % self.content
|
content = '<root>%s</root>' % self.content
|
||||||
tree = self.fromstring(content)
|
tree = self.fromstring(content)
|
||||||
try:
|
try:
|
||||||
ignore = self.tostring(tree, encoding=unicode)
|
self.tostring(tree, encoding=unicode)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
tree = self.soupparser.fromstring(content)
|
tree = self.soupparser.fromstring(content)
|
||||||
return tree
|
return tree
|
||||||
|
Reference in New Issue
Block a user