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