Permalink
Browse files

[1.6.x] Took advantage of django.utils.six.moves.urllib.*.

Backport of 6a6428a from master.
  • Loading branch information...
aaugustin authored and claudep committed Sep 5, 2013
1 parent 960f5bc commit f9f792eb04dfd48d93682070583f473166b490ae
@@ -1,13 +1,10 @@
try:
from urllib.parse import urlparse
except ImportError: # Python 2
from urlparse import urlparse
from functools import wraps from functools import wraps
from django.conf import settings from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.utils.decorators import available_attrs from django.utils.decorators import available_attrs
from django.utils.encoding import force_str from django.utils.encoding import force_str
from django.utils.six.moves.urllib.parse import urlparse
from django.shortcuts import resolve_url from django.shortcuts import resolve_url
@@ -1,10 +1,6 @@
import itertools import itertools
import os import os
import re import re
try:
from urllib.parse import urlparse, ParseResult
except ImportError: # Python 2
from urlparse import urlparse, ParseResult
from django.conf import global_settings, settings from django.conf import global_settings, settings
from django.contrib.sites.models import Site, RequestSite from django.contrib.sites.models import Site, RequestSite
@@ -15,6 +11,7 @@
from django.http import QueryDict, HttpRequest from django.http import QueryDict, HttpRequest
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.http import int_to_base36, urlsafe_base64_decode, urlquote from django.utils.http import int_to_base36, urlsafe_base64_decode, urlquote
from django.utils.six.moves.urllib.parse import urlparse, ParseResult
from django.utils._os import upath from django.utils._os import upath
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings, patch_logger from django.test.utils import override_settings, patch_logger
@@ -1,14 +1,10 @@
try:
from urllib.parse import urlparse, urlunparse
except ImportError: # Python 2
from urlparse import urlparse, urlunparse
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, QueryDict from django.http import HttpResponseRedirect, QueryDict
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.utils.http import base36_to_int, is_safe_url, urlsafe_base64_decode, urlsafe_base64_encode from django.utils.http import base36_to_int, is_safe_url, urlsafe_base64_decode, urlsafe_base64_encode
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.six.moves.urllib.parse import urlparse, urlunparse
from django.shortcuts import resolve_url from django.shortcuts import resolve_url
from django.utils.encoding import force_bytes, force_text from django.utils.encoding import force_bytes, force_text
from django.views.decorators.debug import sensitive_post_parameters from django.views.decorators.debug import sensitive_post_parameters
@@ -3,17 +3,14 @@
""" """
import textwrap import textwrap
try:
from urllib.parse import urlencode
except ImportError: # Python 2
from urllib import urlencode
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, resolve_url from django.shortcuts import render_to_response, resolve_url
from django.template import RequestContext from django.template import RequestContext
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.contrib import comments from django.contrib import comments
from django.utils.http import is_safe_url from django.utils.http import is_safe_url
from django.utils.six.moves.urllib.parse import urlencode
def next_redirect(request, fallback, **get_kwargs): def next_redirect(request, fallback, **get_kwargs):
""" """
@@ -1,11 +1,8 @@
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.core import urlresolvers, paginator from django.core import urlresolvers, paginator
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
try: from django.utils.six.moves.urllib.parse import urlencode
from urllib.parse import urlencode from django.utils.six.moves.urllib.request import urlopen
from urllib.request import urlopen
except ImportError: # Python 2
from urllib import urlencode, urlopen
PING_URL = "http://www.google.com/webmasters/tools/ping" PING_URL = "http://www.google.com/webmasters/tools/ping"
@@ -1,13 +1,8 @@
try:
from urllib.parse import urlparse
from urllib.request import url2pathname
except ImportError: # Python 2
from urllib import url2pathname
from urlparse import urlparse
from django.conf import settings from django.conf import settings
from django.core.handlers.base import get_path_info from django.core.handlers.base import get_path_info
from django.core.handlers.wsgi import WSGIHandler from django.core.handlers.wsgi import WSGIHandler
from django.utils.six.moves.urllib.parse import urlparse
from django.utils.six.moves.urllib.request import url2pathname
from django.contrib.staticfiles import utils from django.contrib.staticfiles import utils
from django.contrib.staticfiles.views import serve from django.contrib.staticfiles.views import serve
@@ -3,11 +3,6 @@
import os import os
import posixpath import posixpath
import re import re
try:
from urllib.parse import unquote, urlsplit, urlunsplit, urldefrag
except ImportError: # Python 2
from urllib import unquote
from urlparse import urlsplit, urlunsplit, urldefrag
from django.conf import settings from django.conf import settings
from django.core.cache import (get_cache, InvalidCacheBackendError, from django.core.cache import (get_cache, InvalidCacheBackendError,
@@ -19,6 +14,7 @@
from django.utils.encoding import force_bytes, force_text from django.utils.encoding import force_bytes, force_text
from django.utils.functional import LazyObject from django.utils.functional import LazyObject
from django.utils.importlib import import_module from django.utils.importlib import import_module
from django.utils.six.moves.urllib.parse import unquote, urlsplit, urlunsplit, urldefrag
from django.utils._os import upath from django.utils._os import upath
from django.contrib.staticfiles.utils import check_settings, matches_patterns from django.contrib.staticfiles.utils import check_settings, matches_patterns
@@ -5,14 +5,11 @@
""" """
import os import os
import posixpath import posixpath
try:
from urllib.parse import unquote
except ImportError: # Python 2
from urllib import unquote
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.http import Http404 from django.http import Http404
from django.utils.six.moves.urllib.parse import unquote
from django.views import static from django.views import static
from django.contrib.staticfiles import finders from django.contrib.staticfiles import finders
@@ -14,10 +14,6 @@
See docs/topics/cache.txt for information on the public API. See docs/topics/cache.txt for information on the public API.
""" """
try:
from urllib.parse import parse_qsl
except ImportError: # Python 2
from urlparse import parse_qsl
from django.conf import settings from django.conf import settings
from django.core import signals from django.core import signals
@@ -26,6 +22,7 @@
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.utils import importlib from django.utils import importlib
from django.utils.module_loading import import_by_path from django.utils.module_loading import import_by_path
from django.utils.six.moves.urllib.parse import parse_qsl
__all__ = [ __all__ = [
@@ -1,9 +1,5 @@
import os import os
import errno import errno
try:
from urllib.parse import urljoin
except ImportError: # Python 2
from urlparse import urljoin
import itertools import itertools
from datetime import datetime from datetime import datetime
@@ -14,6 +10,7 @@
from django.utils.encoding import force_text, filepath_to_uri from django.utils.encoding import force_text, filepath_to_uri
from django.utils.functional import LazyObject from django.utils.functional import LazyObject
from django.utils.module_loading import import_by_path from django.utils.module_loading import import_by_path
from django.utils.six.moves.urllib.parse import urljoin
from django.utils.text import get_valid_filename from django.utils.text import get_valid_filename
from django.utils._os import safe_join, abspathu from django.utils._os import safe_join, abspathu
@@ -8,17 +8,14 @@
import stat import stat
import sys import sys
import tempfile import tempfile
try:
from urllib.request import urlretrieve
except ImportError: # Python 2
from urllib import urlretrieve
from optparse import make_option from optparse import make_option
from os import path from os import path
import django import django
from django.template import Template, Context from django.template import Template, Context
from django.utils import archive from django.utils import archive
from django.utils.six.moves.urllib.request import urlretrieve
from django.utils._os import rmtree_errorhandler from django.utils._os import rmtree_errorhandler
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import handle_extensions from django.core.management.utils import handle_extensions
@@ -13,18 +13,15 @@
import socket import socket
import sys import sys
import traceback import traceback
try:
from urllib.parse import urljoin
except ImportError: # Python 2
from urlparse import urljoin
from django.utils.six.moves import socketserver
from wsgiref import simple_server from wsgiref import simple_server
from wsgiref.util import FileWrapper # for backwards compatibility from wsgiref.util import FileWrapper # for backwards compatibility
from django.core.management.color import color_style from django.core.management.color import color_style
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
from django.utils.module_loading import import_by_path from django.utils.module_loading import import_by_path
from django.utils import six from django.utils import six
from django.utils.six.moves.urllib.parse import urljoin
from django.utils.six.moves import socketserver
__all__ = ('WSGIServer', 'WSGIRequestHandler', 'MAX_SOCKET_CHUNK_SIZE') __all__ = ('WSGIServer', 'WSGIRequestHandler', 'MAX_SOCKET_CHUNK_SIZE')
@@ -1,16 +1,14 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re
try:
from urllib.parse import urlsplit, urlunsplit
except ImportError: # Python 2
from urlparse import urlsplit, urlunsplit
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _, ungettext_lazy from django.utils.translation import ugettext_lazy as _, ungettext_lazy
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
# These values, if given to validate(), will trigger the self.required check. # These values, if given to validate(), will trigger the self.required check.
EMPTY_VALUES = (None, '', [], (), {}) EMPTY_VALUES = (None, '', [], (), {})
View
@@ -9,10 +9,6 @@
import os import os
import re import re
import sys import sys
try:
from urllib.parse import urlsplit, urlunsplit
except ImportError: # Python 2
from urlparse import urlsplit, urlunsplit
from decimal import Decimal, DecimalException from decimal import Decimal, DecimalException
from io import BytesIO from io import BytesIO
@@ -29,6 +25,7 @@
from django.utils.encoding import smart_text, force_str, force_text from django.utils.encoding import smart_text, force_str, force_text
from django.utils.ipv6 import clean_ipv6_address from django.utils.ipv6 import clean_ipv6_address
from django.utils import six from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import ugettext_lazy as _, ungettext_lazy from django.utils.translation import ugettext_lazy as _, ungettext_lazy
# Provide this import for backwards compatibility. # Provide this import for backwards compatibility.
View
@@ -6,10 +6,6 @@
import copy import copy
from itertools import chain from itertools import chain
try:
from urllib.parse import urljoin
except ImportError: # Python 2
from urlparse import urljoin
import warnings import warnings
from django.conf import settings from django.conf import settings
@@ -20,6 +16,7 @@
from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils import datetime_safe, formats, six from django.utils import datetime_safe, formats, six
from django.utils.six.moves.urllib.parse import urljoin
__all__ = ( __all__ = (
'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'Media', 'MediaDefiningClass', 'Widget', 'TextInput',
@@ -1,11 +1,7 @@
try:
from urllib.parse import urljoin
except ImportError: # Python 2
from urlparse import urljoin
from django import template from django import template
from django.template.base import Node from django.template.base import Node
from django.utils.encoding import iri_to_uri from django.utils.encoding import iri_to_uri
from django.utils.six.moves.urllib.parse import urljoin
register = template.Library() register = template.Library()
View
@@ -6,11 +6,6 @@
import mimetypes import mimetypes
from copy import copy from copy import copy
from io import BytesIO from io import BytesIO
try:
from urllib.parse import unquote, urlparse, urlsplit
except ImportError: # Python 2
from urllib import unquote
from urlparse import urlparse, urlsplit
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate, login, logout, get_user_model from django.contrib.auth import authenticate, login, logout, get_user_model
@@ -28,6 +23,7 @@
from django.utils.importlib import import_module from django.utils.importlib import import_module
from django.utils.itercompat import is_iterable from django.utils.itercompat import is_iterable
from django.utils import six from django.utils import six
from django.utils.six.moves.urllib.parse import unquote, urlparse, urlsplit
from django.test.utils import ContextList from django.test.utils import ContextList
__all__ = ('Client', 'RequestFactory', 'encode_file', 'encode_multipart') __all__ = ('Client', 'RequestFactory', 'encode_file', 'encode_multipart')
View
@@ -8,10 +8,6 @@
import os import os
import re import re
import sys import sys
try:
from urllib.parse import urlsplit, urlunsplit
except ImportError: # Python 2
from urlparse import urlsplit, urlunsplit
import select import select
import socket import socket
import threading import threading
@@ -39,6 +35,7 @@
override_settings, compare_xml) override_settings, compare_xml)
from django.utils import six, unittest as ut2 from django.utils import six, unittest as ut2
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.unittest import skipIf # Imported here for backward compatibility from django.utils.unittest import skipIf # Imported here for backward compatibility
from django.utils.unittest.util import safe_repr from django.utils.unittest.util import safe_repr
from django.views.static import serve from django.views.static import serve
View
@@ -4,14 +4,11 @@
import datetime import datetime
from decimal import Decimal from decimal import Decimal
import locale import locale
try:
from urllib.parse import quote
except ImportError: # Python 2
from urllib import quote
import warnings import warnings
from django.utils.functional import Promise from django.utils.functional import Promise
from django.utils import six from django.utils import six
from django.utils.six.moves.urllib.parse import quote
class DjangoUnicodeDecodeError(UnicodeDecodeError): class DjangoUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, obj, *args): def __init__(self, obj, *args):
@@ -24,15 +24,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import datetime import datetime
try:
from urllib.parse import urlparse
except ImportError: # Python 2
from urlparse import urlparse
from django.utils.xmlutils import SimplerXMLGenerator from django.utils.xmlutils import SimplerXMLGenerator
from django.utils.encoding import force_text, iri_to_uri from django.utils.encoding import force_text, iri_to_uri
from django.utils import datetime_safe from django.utils import datetime_safe
from django.utils import six from django.utils import six
from django.utils.six import StringIO from django.utils.six import StringIO
from django.utils.six.moves.urllib.parse import urlparse
from django.utils.timezone import is_aware from django.utils.timezone import is_aware
def rfc2822_date(date): def rfc2822_date(date):
View
@@ -3,16 +3,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re
try:
from urllib.parse import quote, unquote, urlsplit, urlunsplit
except ImportError: # Python 2
from urllib import quote, unquote
from urlparse import urlsplit, urlunsplit
from django.utils.safestring import SafeData, mark_safe from django.utils.safestring import SafeData, mark_safe
from django.utils.encoding import force_text, force_str from django.utils.encoding import force_text, force_str
from django.utils.functional import allow_lazy from django.utils.functional import allow_lazy
from django.utils import six from django.utils import six
from django.utils.six.moves.urllib.parse import quote, unquote, urlsplit, urlunsplit
from django.utils.text import normalize_newlines from django.utils.text import normalize_newlines
from .html_parser import HTMLParser, HTMLParseError from .html_parser import HTMLParser, HTMLParseError
Oops, something went wrong.

0 comments on commit f9f792e

Please sign in to comment.