Added url2pathname function to compat module

This commit is contained in:
Rafal Stozek
2013-03-21 20:22:18 +01:00
parent 284b02f917
commit 763af8861d
2 changed files with 9 additions and 4 deletions

View File

@@ -1,9 +1,7 @@
from __future__ import with_statement, unicode_literals
import os
import codecs
import urllib
import six
from django.core.files.base import ContentFile
from django.template import Context
from django.template.loader import render_to_string
@@ -11,7 +9,7 @@ from django.utils.importlib import import_module
from django.utils.safestring import mark_safe
from compressor.cache import get_hexdigest, get_mtime
from compressor.utils.compat import smart_text
from compressor.utils.compat import smart_text, url2pathname
from compressor.conf import settings
from compressor.exceptions import (CompressorError, UncompressableFileError,
FilterDoesNotExist)
@@ -120,7 +118,7 @@ class Compressor(object):
filename = compressor_file_storage.path(basename)
# secondly try to find it with staticfiles (in debug mode)
if not filename and self.finders:
filename = self.finders.find(urllib.url2pathname(basename))
filename = self.finders.find(url2pathname(basename))
if filename:
return filename
# or just raise an exception as the last resort

View File

@@ -1,3 +1,4 @@
# noqa
import six
try:
@@ -26,3 +27,9 @@ else:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
try:
from urllib.request import url2pathname
except ImportError:
from urllib import url2pathname