Commit c66df66a by Timothée Peignier

moving things and upgrading things around

parent 0922436a
...@@ -2,6 +2,6 @@ language: python ...@@ -2,6 +2,6 @@ language: python
python: python:
- 2.7 - 2.7
install: pip install tox --use-mirrors install: pip install tox --use-mirrors
script: tox -e py26-1.2.X,py27-1.2.X,py26-1.3.X,py27-1.3.X,py26,py27,docs script: tox
notifications: notifications:
irc: "irc.freenode.org#django-pipeline" irc: "irc.freenode.org#django-pipeline"
\ No newline at end of file
import os import os
import subprocess import subprocess
try: from django.contrib.staticfiles import finders
from staticfiles import finders
except ImportError:
from django.contrib.staticfiles import finders # noqa
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.utils.encoding import smart_str from django.utils.encoding import smart_str
...@@ -102,6 +99,6 @@ class SubProcessCompiler(CompilerBase): ...@@ -102,6 +99,6 @@ class SubProcessCompiler(CompilerBase):
raise CompilerError(error) raise CompilerError(error)
if self.verbose: if self.verbose:
print error print(error)
return compressed_content return compressed_content
...@@ -6,12 +6,9 @@ import subprocess ...@@ -6,12 +6,9 @@ import subprocess
from itertools import takewhile from itertools import takewhile
from django.utils.encoding import smart_str, force_unicode from django.utils.encoding import smart_bytes, force_text
try: from django.contrib.staticfiles import finders
from staticfiles import finders
except ImportError:
from django.contrib.staticfiles import finders # noqa
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.storage import default_storage from pipeline.storage import default_storage
...@@ -89,8 +86,8 @@ class Compressor(object): ...@@ -89,8 +86,8 @@ class Compressor(object):
base_path = self.base_path(paths) base_path = self.base_path(paths)
for path in paths: for path in paths:
contents = self.read_file(path) contents = self.read_file(path)
contents = re.sub(r"\r?\n", "\\\\n", contents) contents = re.sub("\r?\n", "\\\\n", contents)
contents = re.sub(r"'", "\\'", contents) contents = re.sub("'", "\\'", contents)
name = self.template_name(path, base_path) name = self.template_name(path, base_path)
compiled += "%s['%s'] = %s('%s');\n" % ( compiled += "%s['%s'] = %s('%s');\n" % (
namespace, namespace,
...@@ -135,7 +132,7 @@ class Compressor(object): ...@@ -135,7 +132,7 @@ class Compressor(object):
return "url(%s)" % asset_url return "url(%s)" % asset_url
content = self.read_file(path) content = self.read_file(path)
# content needs to be unicode to avoid explosions with non-ascii chars # content needs to be unicode to avoid explosions with non-ascii chars
content = re.sub(URL_DETECTOR, reconstruct, force_unicode(content)) content = re.sub(URL_DETECTOR, reconstruct, force_text(content))
stylesheets.append(content) stylesheets.append(content)
return '\n'.join(stylesheets) return '\n'.join(stylesheets)
...@@ -232,7 +229,7 @@ class SubProcessCompressor(CompressorBase): ...@@ -232,7 +229,7 @@ class SubProcessCompressor(CompressorBase):
def execute_command(self, command, content): def execute_command(self, command, content):
pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stderr=subprocess.PIPE) stdin=subprocess.PIPE, stderr=subprocess.PIPE)
pipe.stdin.write(smart_str(content)) pipe.stdin.write(smart_bytes(content))
pipe.stdin.close() pipe.stdin.close()
compressed_content = pipe.stdout.read() compressed_content = pipe.stdout.read()
...@@ -247,5 +244,5 @@ class SubProcessCompressor(CompressorBase): ...@@ -247,5 +244,5 @@ class SubProcessCompressor(CompressorBase):
raise CompressorError(error) raise CompressorError(error)
if self.verbose: if self.verbose:
print error print(error)
return compressed_content return compressed_content
import inspect import inspect
try: from django.contrib.staticfiles.storage import staticfiles_storage
from staticfiles.storage import staticfiles_storage
except ImportError:
from django.contrib.staticfiles.storage import staticfiles_storage # noqa
from django.conf import settings as django_settings from django.conf import settings as django_settings
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
...@@ -48,7 +45,7 @@ class Jinja2Compressed(object): ...@@ -48,7 +45,7 @@ class Jinja2Compressed(object):
val = val if val else "''" val = val if val else "''"
expr = "pipeline_settings.%s = %s" % ( expr = "pipeline_settings.%s = %s" % (
setting, val) setting, val)
exec expr exec(expr)
pipeline_settings.PIPELINE = getattr(django_settings, pipeline_settings.PIPELINE = getattr(django_settings,
'PIPELINE', not django_settings.DEBUG) 'PIPELINE', not django_settings.DEBUG)
self.settings = pipeline_settings self.settings = pipeline_settings
......
import os import os
try: from django.contrib.staticfiles.finders import get_finders
from staticfiles.finders import get_finders
except ImportError:
from django.contrib.staticfiles.finders import get_finders # noqa
from pipeline.conf import settings from pipeline.conf import settings
......
...@@ -95,7 +95,7 @@ class Packager(object): ...@@ -95,7 +95,7 @@ class Packager(object):
def pack(self, package, compress, signal, **kwargs): def pack(self, package, compress, signal, **kwargs):
output_filename = package.output_filename output_filename = package.output_filename
if self.verbose: if self.verbose:
print "Saving: %s" % output_filename print("Saving: %s" % output_filename)
paths = self.compile(package.paths, force=True) paths = self.compile(package.paths, force=True)
content = compress(paths, **kwargs) content = compress(paths, **kwargs)
self.save_file(output_filename, content) self.save_file(output_filename, content)
......
import os import os
try: from django.contrib.staticfiles import finders
from staticfiles import finders from django.contrib.staticfiles.storage import CachedFilesMixin, StaticFilesStorage
from staticfiles.storage import CachedFilesMixin, StaticFilesStorage
except ImportError:
from django.contrib.staticfiles import finders # noqa
from django.contrib.staticfiles.storage import CachedFilesMixin, StaticFilesStorage # noqa
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import get_storage_class from django.core.files.storage import get_storage_class
......
try: from django.contrib.staticfiles.storage import staticfiles_storage
from staticfiles.storage import staticfiles_storage
except ImportError:
from django.contrib.staticfiles.storage import staticfiles_storage # noqa
from django import template from django import template
from django.template.loader import render_to_string from django.template.loader import render_to_string
......
...@@ -13,7 +13,7 @@ SITE_ID = 1 ...@@ -13,7 +13,7 @@ SITE_ID = 1
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sites', 'django.contrib.sites',
'staticfiles', 'django.contrib.staticfiles',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.admin', 'django.contrib.admin',
'pipeline', 'pipeline',
...@@ -32,8 +32,8 @@ STATICFILES_DIRS = ( ...@@ -32,8 +32,8 @@ STATICFILES_DIRS = (
local_path('assets2/'), local_path('assets2/'),
) )
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder' 'django.contrib.staticfiles.finders.AppDirectoriesFinder'
) )
SECRET_KEY = "django-pipeline" SECRET_KEY = "django-pipeline"
......
# -*- coding: utf-8 flake8: noqa -*- # -*- coding: utf-8 flake8: noqa -*-
from compiler import * from .test_compiler import *
from compressor import * from .test_compressor import *
from glob import * from .test_glob import *
from jinja2 import * from .test_jinja2 import *
from packager import * from .test_packager import *
from storage import * from .test_storage import *
from utils import * from .test_utils import *
...@@ -3,7 +3,7 @@ from django.test import TestCase ...@@ -3,7 +3,7 @@ from django.test import TestCase
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.compilers import Compiler, CompilerBase from pipeline.compilers import Compiler, CompilerBase
from paths import _ from tests.utils import _
class DummyCompiler(CompilerBase): class DummyCompiler(CompilerBase):
...@@ -20,7 +20,7 @@ class CompilerTest(TestCase): ...@@ -20,7 +20,7 @@ class CompilerTest(TestCase):
def setUp(self): def setUp(self):
self.compiler = Compiler() self.compiler = Compiler()
self.old_compilers = settings.PIPELINE_COMPILERS self.old_compilers = settings.PIPELINE_COMPILERS
settings.PIPELINE_COMPILERS = ['tests.tests.compiler.DummyCompiler'] settings.PIPELINE_COMPILERS = ['tests.tests.test_compiler.DummyCompiler']
def test_output_path(self): def test_output_path(self):
output_path = self.compiler.output_path("js/helpers.coffee", "js") output_path = self.compiler.output_path("js/helpers.coffee", "js")
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import base64 import base64
from mock import patch try:
from mock import patch
except:
from unittest.mock import patch
from django.test import TestCase from django.test import TestCase
from pipeline.compressors import Compressor, TEMPLATE_FUNC from pipeline.compressors import Compressor, TEMPLATE_FUNC
from pipeline.compressors.yui import YUICompressor from pipeline.compressors.yui import YUICompressor
from paths import _ from tests.utils import _
class CompressorTest(TestCase): class CompressorTest(TestCase):
......
...@@ -2,7 +2,7 @@ from django.test import TestCase ...@@ -2,7 +2,7 @@ from django.test import TestCase
from pipeline.packager import Packager, PackageNotFound from pipeline.packager import Packager, PackageNotFound
from paths import _ from tests.utils import _
class PackagerTest(TestCase): class PackagerTest(TestCase):
......
...@@ -3,7 +3,8 @@ from django.utils.datastructures import SortedDict ...@@ -3,7 +3,8 @@ from django.utils.datastructures import SortedDict
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.storage import PipelineStorage from pipeline.storage import PipelineStorage
from paths import _
from tests.utils import _
class StorageTest(TestCase): class StorageTest(TestCase):
......
[tox] [tox]
envlist = envlist =
py25-1.2.X, py26-1.2.X, py27-1.2.X, py26-1.4.X, py27-1.4.X, pypy-1.4.X,
py25-1.3.X, py26-1.3.X, py27-1.3.X, py26, py27, pypy, py33, docs
py25, py26, py27, pypy, docs
[testenv] [testenv]
downloadcache = {toxworkdir}/_download/ downloadcache = {toxworkdir}/_download/
...@@ -12,96 +11,60 @@ setenv = ...@@ -12,96 +11,60 @@ setenv =
commands = commands =
{envbindir}/django-admin.py test {posargs:tests} {envbindir}/django-admin.py test {posargs:tests}
[testenv:py25-1.2.X] [testenv:py26-1.4.X]
basepython = python2.5
deps =
Django==1.2.4
mock
django-staticfiles==1.2.1
unittest2
jinja2
[testenv:py26-1.2.X]
basepython = python2.6
deps =
Django==1.2.4
mock
django-staticfiles==1.2.1
unittest2
jinja2
[testenv:py27-1.2.X]
basepython = python2.7
deps =
Django==1.2.4
mock
django-staticfiles==1.2.1
unittest2
jinja2
[testenv:py25-1.3.X]
basepython = python2.5
deps =
Django==1.3.1
mock
django-staticfiles==1.2.1
unittest2
jinja2
[testenv:py26-1.3.X]
basepython = python2.6 basepython = python2.6
deps = deps =
Django==1.3.1 Django==1.4.2
mock mock
django-staticfiles==1.2.1
unittest2 unittest2
jinja2 jinja2
[testenv:py27-1.3.X] [testenv:py27-1.4.X]
basepython = python2.7 basepython = python2.7
deps = deps =
Django==1.3.1 Django==1.4.2
mock mock
django-staticfiles==1.2.1
unittest2 unittest2
jinja2 jinja2
[testenv:py25] [testenv:pypy-1.4.X]
basepython = python2.5 basepython = pypy
deps = deps =
Django==1.4 Django==1.4.2
mock mock
django-staticfiles==1.2.1
unittest2 unittest2
jinja2 jinja2
[testenv:py26] [testenv:py26]
basepython = python2.6 basepython = python2.6
deps = deps =
Django==1.4 https://www.djangoproject.com/download/1.5a1/tarball/
mock mock
django-staticfiles==1.2.1
unittest2 unittest2
jinja2 jinja2
[testenv:py27] [testenv:py27]
basepython = python2.7 basepython = python2.7
deps = deps =
Django==1.4 https://www.djangoproject.com/download/1.5a1/tarball/
mock mock
django-staticfiles==1.2.1
unittest2 unittest2
jinja2 jinja2
[testenv:pypy] [testenv:pypy]
basepython = pypy basepython = pypy
deps = deps =
Django==1.4 https://www.djangoproject.com/download/1.5a1/tarball/
mock mock
django-staticfiles==1.2.1
unittest2 unittest2
jinja2 jinja2
[testenv:py33]
basepython = python3.3
deps =
jinja2
https://www.djangoproject.com/download/1.5a1/tarball/
[testenv:docs] [testenv:docs]
basepython = python2.7 basepython = python2.7
changedir = docs changedir = docs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment