Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup static collect when developt #460

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pipeline/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@


class Collector(object):
is_collected = False

def __init__(self, storage=None):
if storage is None:
storage = staticfiles_storage
Expand All @@ -24,7 +26,9 @@ def clear(self, path=""):
for d in dirs:
self.clear(os.path.join(path, d))

def collect(self):
def collect(self, collect=None):
if not collect and self.is_collected:
return
found_files = OrderedDict()
for finder in finders.get_finders():
# Ignore our finder to avoid looping
Expand All @@ -39,6 +43,7 @@ def collect(self):
if prefixed_path not in found_files:
found_files[prefixed_path] = (storage, path)
self.copy_file(path, prefixed_path, storage)
self.is_collected = True

def copy_file(self, path, prefixed_path, source_storage):
# Delete the target file if needed or break
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def compile_file(self, infile, outfile, outdated=False, force=False):

class CompilerTest(TestCase):
def setUp(self):
default_collector.collect()
default_collector.collect(True)
self.compiler = Compiler()
self.old_compilers = settings.PIPELINE_COMPILERS
settings.PIPELINE_COMPILERS = ['tests.tests.test_compiler.DummyCompiler']
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CompressorTest(TestCase):
def setUp(self):
self.maxDiff = None
self.compressor = Compressor()
default_collector.collect()
default_collector.collect(True)

def test_js_compressor_class(self):
self.assertEqual(self.compressor.js_compressor, YuglifyCompressor)
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class PackagerTest(TestCase):
def setUp(self):
default_collector.collect()
default_collector.collect(True)

def test_package_for(self):
packager = Packager()
Expand Down
2 changes: 2 additions & 0 deletions tests/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.template import Template, Context
from django.test import TestCase

from pipeline.collector import default_collector
from pipeline.templatetags.ext import PipelineExtension

from tests.utils import pipeline_settings
Expand All @@ -15,6 +16,7 @@ class JinjaTest(TestCase):
def setUp(self):
self.env = Environment(extensions=[PipelineExtension],
loader=PackageLoader('pipeline', 'templates'))
default_collector.collect(True)

def test_no_package(self):
template = self.env.from_string(u"""{% stylesheet "unknow" %}""")
Expand Down