Commit 3cf8257f by Timothée Peignier

improve python3 support

parent c66df66a
from __future__ import unicode_literals
import os
import subprocess
......
from __future__ import unicode_literals
from pipeline.conf import settings
from pipeline.compilers import SubProcessCompiler
......
from __future__ import unicode_literals
from os.path import dirname
from pipeline.conf import settings
......
from __future__ import unicode_literals
from os.path import dirname
from pipeline.conf import settings
......
from __future__ import unicode_literals
from os.path import dirname
from pipeline.conf import settings
......
from __future__ import unicode_literals
import base64
import os
import posixpath
......@@ -8,8 +10,6 @@ from itertools import takewhile
from django.utils.encoding import smart_bytes, force_text
from django.contrib.staticfiles import finders
from pipeline.conf import settings
from pipeline.storage import default_storage
from pipeline.utils import to_class, relpath
......@@ -86,8 +86,8 @@ class Compressor(object):
base_path = self.base_path(paths)
for path in paths:
contents = self.read_file(path)
contents = re.sub("\r?\n", "\\\\n", contents)
contents = re.sub("'", "\\'", contents)
contents = re.sub(b"\r?\n", b"\\\\n", contents)
contents = re.sub(b"'", b"\\'", contents)
name = self.template_name(path, base_path)
compiled += "%s['%s'] = %s('%s');\n" % (
namespace,
......@@ -138,7 +138,7 @@ class Compressor(object):
def concatenate(self, paths):
"""Concatenate together a list of files"""
return '\n'.join([self.read_file(path) for path in paths])
return b"\n".join([self.read_file(path) for path in paths])
def construct_asset_path(self, asset_path, css_path, output_filename, variant=None):
"""Return a rewritten asset URL for a stylesheet"""
......@@ -203,7 +203,7 @@ class Compressor(object):
def read_file(self, path):
"""Read file content in binary mode"""
file = default_storage.open(path, 'rb')
file = default_storage.open(path)
content = file.read()
file.close()
return content
......
from __future__ import unicode_literals
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
......
from __future__ import unicode_literals
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
......
from __future__ import unicode_literals
from django.core.files import temp as tempfile
from pipeline.conf import settings
......
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
from pipeline.compressors import CompressorBase
......
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
from pipeline.compressors import CompressorBase
......
from __future__ import unicode_literals
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
......
from __future__ import unicode_literals
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
......
from __future__ import unicode_literals
from django.conf import settings
PIPELINE = getattr(settings, 'PIPELINE', not settings.DEBUG)
......
from __future__ import unicode_literals
import os
import re
import fnmatch
......
from __future__ import unicode_literals
import inspect
from django.contrib.staticfiles.storage import staticfiles_storage
......
from __future__ import unicode_literals
import os
from django.contrib.staticfiles.finders import get_finders
......
from __future__ import unicode_literals
from django.utils.encoding import DjangoUnicodeDecodeError
from django.utils.html import strip_spaces_between_tags as minify_html
......
from __future__ import unicode_literals
from django.core.files.base import ContentFile
from django.utils.encoding import smart_str
......
from __future__ import unicode_literals
from django.dispatch import Signal
......
from __future__ import unicode_literals
import os
from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import CachedFilesMixin, StaticFilesStorage
from django.contrib.staticfiles.storage import CachedFilesMixin, StaticFilesStorage # noqa
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import get_storage_class
......
from django.contrib.staticfiles.storage import staticfiles_storage
from __future__ import unicode_literals
from django.contrib.staticfiles.storage import staticfiles_storage # noqa
from django import template
from django.template.loader import render_to_string
......
from __future__ import unicode_literals
import mimetypes
import posixpath
import urllib
......
from __future__ import unicode_literals
from django.test import TestCase
from pipeline.conf import settings
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import base64
try:
from mock import patch
except:
from unittest.mock import patch
from unittest.mock import patch # noqa
from django.test import TestCase
......@@ -37,7 +39,7 @@ class CompressorTest(TestCase):
_('pipeline/js/first.js'),
_('pipeline/js/second.js')
])
self.assertEquals("""function concat() {\n console.log(arguments);\n}\n\nfunction cat() {\n console.log("hello world");\n}\n""", js)
self.assertEquals(b"""function concat() {\n console.log(arguments);\n}\n\nfunction cat() {\n console.log("hello world");\n}\n""", js)
@patch.object(base64, 'b64encode')
def test_encoded_content(self, mock):
......@@ -102,7 +104,7 @@ class CompressorTest(TestCase):
output = self.compressor.concatenate_and_rewrite([
_('pipeline/css/urls.css'),
], 'css/screen.css')
self.assertEquals(u"""@font-face {
self.assertEquals("""@font-face {
font-family: 'Pipeline';
src: url(../pipeline/fonts/pipeline.eot);
src: url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype');
......
from __future__ import unicode_literals
import os
import shutil
......
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
from django.conf import settings
from django.test import TestCase
......
from __future__ import unicode_literals
from django.test import TestCase
from pipeline.packager import Packager, PackageNotFound
......
from __future__ import unicode_literals
from django.test import TestCase
from django.utils.datastructures import SortedDict
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from pipeline.utils import guess_type
......
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