From 29f0e8182f49e2927ae46e748d09d0672d4fc127 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 22 Jul 2008 03:24:09 +0000 Subject: [PATCH] Fixed #7847 -- Removed a whole bunch of unused imports from throughout the codebase. Thanks, julien git-svn-id: http://code.djangoproject.com/svn/django/trunk@8046 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/options.py | 3 +- django/contrib/admin/views/main.py | 1 - django/contrib/admin/widgets.py | 3 +- django/contrib/admindocs/views.py | 2 +- django/contrib/auth/admin.py | 2 +- django/contrib/auth/decorators.py | 4 +-- django/contrib/auth/forms.py | 1 - .../management/commands/createsuperuser.py | 2 +- .../contrib/databrowse/plugins/calendars.py | 1 - .../databrowse/plugins/fieldchoices.py | 1 - django/contrib/databrowse/sites.py | 2 +- django/contrib/databrowse/views.py | 2 -- django/contrib/formtools/tests.py | 1 - django/contrib/sessions/backends/cache.py | 2 -- django/contrib/sessions/backends/db.py | 3 -- django/contrib/syndication/feeds.py | 2 +- django/core/files/uploadhandler.py | 3 +- .../management/commands/compilemessages.py | 1 - django/core/management/commands/test.py | 1 - django/core/management/commands/testserver.py | 1 - django/db/backends/oracle/base.py | 1 - django/db/models/__init__.py | 2 -- django/db/models/base.py | 3 +- django/db/models/fields/related.py | 2 -- django/db/models/sql/query.py | 1 - django/dispatch/dispatcher.py | 32 +++++++++---------- django/dispatch/saferef.py | 1 - django/forms/fields.py | 2 +- django/forms/formsets.py | 2 +- django/forms/models.py | 1 - django/forms/util.py | 1 - django/utils/dateformat.py | 2 +- django/utils/encoding.py | 2 -- django/views/generic/simple.py | 1 - 34 files changed, 30 insertions(+), 61 deletions(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 6b000ff97f7..c6bfbee9246 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1,5 +1,4 @@ -from django import oldforms, template -from django import forms +from django import forms, template from django.forms.formsets import all_valid from django.forms.models import modelform_factory, inlineformset_factory from django.forms.models import BaseInlineFormset diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 926270cc689..116d9d49f1c 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -6,7 +6,6 @@ from django.db import models from django.db.models.query import QuerySet from django.utils.encoding import force_unicode, smart_str from django.utils.translation import ugettext -from django.utils.safestring import mark_safe from django.utils.http import urlencode import operator diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index 1139f8af606..1737920312e 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -7,8 +7,7 @@ import copy from django import forms from django.forms.widgets import RadioFieldRenderer from django.forms.util import flatatt -from django.utils.datastructures import MultiValueDict -from django.utils.text import capfirst, truncate_words +from django.utils.text import truncate_words from django.utils.translation import ugettext as _ from django.utils.safestring import mark_safe from django.utils.encoding import force_unicode diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index e81293adcb9..d6d263c8516 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -5,7 +5,7 @@ from django.contrib.admin.views.decorators import staff_member_required from django.db import models from django.shortcuts import render_to_response from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist -from django.http import Http404, get_host +from django.http import Http404 from django.core import urlresolvers from django.contrib.admindocs import utils from django.contrib.sites.models import Site diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py index 998692a6cb8..f97935d5996 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -1,6 +1,6 @@ from django.contrib.auth.models import User, Group from django.core.exceptions import PermissionDenied -from django import oldforms, template +from django import template from django.shortcuts import render_to_response from django.http import HttpResponseRedirect from django.utils.translation import ugettext, ugettext_lazy as _ diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py index 25bc20780e9..1371c62eeab 100644 --- a/django/contrib/auth/decorators.py +++ b/django/contrib/auth/decorators.py @@ -1,7 +1,7 @@ try: - from functools import wraps, update_wrapper + from functools import update_wrapper except ImportError: - from django.utils.functional import wraps, update_wrapper # Python 2.3, 2.4 fallback. + from django.utils.functional import update_wrapper # Python 2.3, 2.4 fallback. from django.contrib.auth import REDIRECT_FIELD_NAME from django.http import HttpResponseRedirect diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 13ddcd38419..06657488fe2 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -2,7 +2,6 @@ from django.contrib.auth.models import User from django.contrib.auth import authenticate from django.contrib.sites.models import Site from django.template import Context, loader -from django.core import validators from django import forms from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py index 4299762c743..91e39f7235f 100644 --- a/django/contrib/auth/management/commands/createsuperuser.py +++ b/django/contrib/auth/management/commands/createsuperuser.py @@ -7,7 +7,7 @@ import os import re import sys from optparse import make_option -from django.contrib.auth.models import User, UNUSABLE_PASSWORD +from django.contrib.auth.models import User from django.core import validators from django.core.management.base import BaseCommand, CommandError diff --git a/django/contrib/databrowse/plugins/calendars.py b/django/contrib/databrowse/plugins/calendars.py index a4524e20dd3..ac2f5221485 100644 --- a/django/contrib/databrowse/plugins/calendars.py +++ b/django/contrib/databrowse/plugins/calendars.py @@ -4,7 +4,6 @@ from django.contrib.databrowse.datastructures import EasyModel from django.contrib.databrowse.sites import DatabrowsePlugin from django.shortcuts import render_to_response from django.utils.text import capfirst -from django.utils.translation import get_date_formats from django.utils.encoding import force_unicode from django.utils.safestring import mark_safe from django.views.generic import date_based diff --git a/django/contrib/databrowse/plugins/fieldchoices.py b/django/contrib/databrowse/plugins/fieldchoices.py index 0a58e7a6aba..8f77792579d 100644 --- a/django/contrib/databrowse/plugins/fieldchoices.py +++ b/django/contrib/databrowse/plugins/fieldchoices.py @@ -6,7 +6,6 @@ from django.shortcuts import render_to_response from django.utils.text import capfirst from django.utils.encoding import smart_str, force_unicode from django.utils.safestring import mark_safe -from django.views.generic import date_based import urllib class FieldChoicePlugin(DatabrowsePlugin): diff --git a/django/contrib/databrowse/sites.py b/django/contrib/databrowse/sites.py index 5d8c1c8b494..9ef35dbc1ca 100644 --- a/django/contrib/databrowse/sites.py +++ b/django/contrib/databrowse/sites.py @@ -1,6 +1,6 @@ from django import http from django.db import models -from django.contrib.databrowse.datastructures import EasyModel, EasyChoice +from django.contrib.databrowse.datastructures import EasyModel from django.shortcuts import render_to_response from django.utils.safestring import mark_safe diff --git a/django/contrib/databrowse/views.py b/django/contrib/databrowse/views.py index c17aad5d850..4543e95780b 100644 --- a/django/contrib/databrowse/views.py +++ b/django/contrib/databrowse/views.py @@ -1,7 +1,5 @@ -from django.db.models import FieldDoesNotExist, DateTimeField from django.http import Http404 from django.shortcuts import render_to_response -from django.contrib.databrowse.datastructures import EasyModel, EasyChoice ########### # CHOICES # diff --git a/django/contrib/formtools/tests.py b/django/contrib/formtools/tests.py index 99fe80bbb36..2ea0cc90a43 100644 --- a/django/contrib/formtools/tests.py +++ b/django/contrib/formtools/tests.py @@ -1,7 +1,6 @@ from django import forms from django.contrib.formtools import preview from django import http -from django.conf import settings from django.test import TestCase success_string = "Done was called!" diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py index 7e171e8309f..5ffb5a136b6 100644 --- a/django/contrib/sessions/backends/cache.py +++ b/django/contrib/sessions/backends/cache.py @@ -1,8 +1,6 @@ -from django.conf import settings from django.contrib.sessions.backends.base import SessionBase from django.core.cache import cache - class SessionStore(SessionBase): """ A cache-based session store. diff --git a/django/contrib/sessions/backends/db.py b/django/contrib/sessions/backends/db.py index 67132c75609..add3d70074e 100644 --- a/django/contrib/sessions/backends/db.py +++ b/django/contrib/sessions/backends/db.py @@ -1,11 +1,8 @@ import datetime - -from django.conf import settings from django.contrib.sessions.models import Session from django.contrib.sessions.backends.base import SessionBase from django.core.exceptions import SuspiciousOperation - class SessionStore(SessionBase): """ Implements database session store. diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py index 85af79cc270..63d2431883a 100644 --- a/django/contrib/syndication/feeds.py +++ b/django/contrib/syndication/feeds.py @@ -1,5 +1,5 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist -from django.template import Context, loader, Template, TemplateDoesNotExist +from django.template import loader, Template, TemplateDoesNotExist from django.contrib.sites.models import Site, RequestSite from django.utils import feedgenerator from django.utils.encoding import smart_unicode, iri_to_uri diff --git a/django/core/files/uploadhandler.py b/django/core/files/uploadhandler.py index 008a05a1481..fa4d2df804b 100644 --- a/django/core/files/uploadhandler.py +++ b/django/core/files/uploadhandler.py @@ -1,8 +1,7 @@ """ Base file upload handler classes, and the built-in concrete subclasses """ -import os -import tempfile + try: from cStringIO import StringIO except ImportError: diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py index 7a189a426a9..218c70b0f44 100644 --- a/django/core/management/commands/compilemessages.py +++ b/django/core/management/commands/compilemessages.py @@ -2,7 +2,6 @@ import os import sys from optparse import make_option from django.core.management.base import BaseCommand -from django.core.management.color import no_style try: set diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py index f0e13a20692..ef7b197b008 100644 --- a/django/core/management/commands/test.py +++ b/django/core/management/commands/test.py @@ -17,7 +17,6 @@ class Command(BaseCommand): def handle(self, *test_labels, **options): from django.conf import settings - from django.db.models import get_app, get_apps verbosity = int(options.get('verbosity', 1)) interactive = options.get('interactive', True) diff --git a/django/core/management/commands/testserver.py b/django/core/management/commands/testserver.py index 9b169d3d9bb..b409bc91d17 100644 --- a/django/core/management/commands/testserver.py +++ b/django/core/management/commands/testserver.py @@ -17,7 +17,6 @@ class Command(BaseCommand): requires_model_validation = False def handle(self, *fixture_labels, **options): - from django.conf import settings from django.core.management import call_command from django.test.utils import create_test_db diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 334b5af96fa..517be0d78b6 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -8,7 +8,6 @@ import os from django.db.backends import BaseDatabaseWrapper, BaseDatabaseFeatures, BaseDatabaseOperations, util from django.db.backends.oracle import query -from django.utils.datastructures import SortedDict from django.utils.encoding import smart_str, force_unicode # Oracle takes client-side character set encoding from the environment. diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index bd6cc3542dd..18c47e86f33 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -10,8 +10,6 @@ from django.db.models.fields import * from django.db.models.fields.subclassing import SubfieldBase from django.db.models.fields.related import ForeignKey, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel, TABULAR, STACKED from django.db.models import signals -from django.utils.functional import curry -from django.utils.text import capfirst # Admin stages. ADD, CHANGE, BOTH = 1, 2, 3 diff --git a/django/db/models/base.py b/django/db/models/base.py index 36dd5ee5e6e..53307dc14c3 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -12,7 +12,7 @@ import django.db.models.manipulators # Imported to register signal handler. import django.db.models.manager # Ditto. from django.core import validators from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError -from django.db.models.fields import AutoField, ImageField, FieldDoesNotExist +from django.db.models.fields import AutoField, ImageField from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField from django.db.models.query import delete_objects, Q, CollectedObjects from django.db.models.options import Options @@ -20,7 +20,6 @@ from django.db import connection, transaction from django.db.models import signals from django.db.models.loading import register_models, get_model from django.dispatch import dispatcher -from django.utils.datastructures import SortedDict from django.utils.functional import curry from django.utils.encoding import smart_str, force_unicode, smart_unicode from django.core.files.move import file_move_safe diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index febe9884ed5..ca25df25035 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -4,10 +4,8 @@ from django.db.models.fields import AutoField, Field, IntegerField, PositiveInte from django.db.models.related import RelatedObject from django.db.models.query import QuerySet from django.db.models.query_utils import QueryWrapper -from django.utils.text import capfirst from django.utils.translation import ugettext_lazy, string_concat, ungettext, ugettext as _ from django.utils.functional import curry -from django.utils.encoding import smart_unicode from django.core import validators from django import oldforms from django import forms diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ef69d7657ff..f06855611a9 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -7,7 +7,6 @@ databases). The abstraction barrier only works one way: this module has to know all about the internals of models in order to get the information it needs. """ -import datetime from copy import deepcopy from django.utils.tree import Node diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py index 029c59fd3f5..725544446e0 100644 --- a/django/dispatch/dispatcher.py +++ b/django/dispatch/dispatcher.py @@ -25,7 +25,7 @@ Internal attributes: deletion, (considerably speeds up the cleanup process vs. the original code.) """ -import types, weakref +import weakref from django.dispatch import saferef, robustapply, errors __author__ = "Patrick K. O'Brien " @@ -129,7 +129,7 @@ def connect(receiver, signal=Any, sender=Any, weak=True): """ if signal is None: raise errors.DispatcherTypeError( - 'Signal cannot be None (receiver=%r sender=%r)'%( receiver,sender) + 'Signal cannot be None (receiver=%r sender=%r)' % (receiver, sender) ) if weak: receiver = saferef.safeRef(receiver, onDelete=_removeReceiver) @@ -159,7 +159,7 @@ def connect(receiver, signal=Any, sender=Any, weak=True): else: receivers = signals[signal] = [] try: - current = sendersBack.get( receiverID ) + current = sendersBack.get(receiverID) if current is None: sendersBack[ receiverID ] = current = [] if senderkey not in current: @@ -199,7 +199,7 @@ def disconnect(receiver, signal=Any, sender=Any, weak=True): """ if signal is None: raise errors.DispatcherTypeError( - 'Signal cannot be None (receiver=%r sender=%r)'%( receiver,sender) + 'Signal cannot be None (receiver=%r sender=%r)' % (receiver, sender) ) if weak: receiver = saferef.safeRef(receiver) senderkey = id(sender) @@ -226,7 +226,7 @@ def disconnect(receiver, signal=Any, sender=Any, weak=True): ) _cleanupConnections(senderkey, signal) -def getReceivers( sender = Any, signal = Any ): +def getReceivers(sender=Any, signal=Any): """Get list of receivers from global tables This utility function allows you to retrieve the @@ -240,7 +240,7 @@ def getReceivers( sender = Any, signal = Any ): rather than, for instance a list to which you might append new records. - Normally you would use liveReceivers( getReceivers( ...)) + Normally you would use liveReceivers(getReceivers(...)) to retrieve the actual receiver objects as an iterable object. """ @@ -258,7 +258,7 @@ def liveReceivers(receivers): receivers. """ for receiver in receivers: - if isinstance( receiver, WEAKREF_TYPES): + if isinstance(receiver, WEAKREF_TYPES): # Dereference the weak reference. receiver = receiver() if receiver is not None: @@ -268,7 +268,7 @@ def liveReceivers(receivers): -def getAllReceivers( sender = Any, signal = Any ): +def getAllReceivers(sender=Any, signal=Any): """Get list of all receivers from global tables This gets all dereferenced receivers which should receive @@ -363,7 +363,7 @@ def send(signal=Any, sender=Anonymous, *arguments, **named): return responses -def sendExact( signal=Any, sender=Anonymous, *arguments, **named ): +def sendExact(signal=Any, sender=Anonymous, *arguments, **named ): """Send signal only to those receivers registered for exact message sendExact allows for avoiding Any/Anonymous registered @@ -403,7 +403,7 @@ def _removeReceiver(receiver): pass else: try: - receivers.remove( receiver ) + receivers.remove(receiver) except Exception, err: pass _cleanupConnections(senderkey, signal) @@ -439,11 +439,11 @@ def _removeSender(senderkey): senders.pop(senderkey, None) -def _removeBackrefs( senderkey): +def _removeBackrefs(senderkey): """Remove all back-references to this senderkey""" for receiver_list in connections.pop(senderkey, {}).values(): for receiver in receiver_list: - _killBackref( receiver, senderkey ) + _killBackref(receiver, senderkey) def _removeOldBackRefs(senderkey, signal, receiver, receivers): @@ -473,18 +473,18 @@ def _removeOldBackRefs(senderkey, signal, receiver, receivers): found = 1 break if not found: - _killBackref( oldReceiver, senderkey ) + _killBackref(oldReceiver, senderkey) return True return False -def _killBackref( receiver, senderkey ): +def _killBackref(receiver, senderkey): """Do the actual removal of back reference from receiver to senderkey""" receiverkey = id(receiver) - receivers_list = sendersBack.get( receiverkey, () ) + receivers_list = sendersBack.get(receiverkey, ()) while senderkey in receivers_list: try: - receivers_list.remove( senderkey ) + receivers_list.remove(senderkey) except: break if not receivers_list: diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py index c0d2eeb788f..2abe3300da4 100644 --- a/django/dispatch/saferef.py +++ b/django/dispatch/saferef.py @@ -1,6 +1,5 @@ """Refactored "safe reference" from dispatcher.py""" import weakref, traceback -from django.utils.functional import curry def safeRef(target, onDelete = None): """Return a *safe* weak reference to a callable target diff --git a/django/forms/fields.py b/django/forms/fields.py index 134b63a625b..9e55365210a 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -23,7 +23,7 @@ except NameError: from sets import Set as set from django.utils.translation import ugettext_lazy as _ -from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str +from django.utils.encoding import smart_unicode, smart_str from util import ErrorList, ValidationError from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 1ae27bf58cb..65cda801648 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -2,7 +2,7 @@ from forms import Form from django.utils.encoding import StrAndUnicode from django.utils.safestring import mark_safe from fields import IntegerField, BooleanField -from widgets import Media, HiddenInput, TextInput +from widgets import Media, HiddenInput from util import ErrorList, ValidationError __all__ = ('BaseFormSet', 'all_valid') diff --git a/django/forms/models.py b/django/forms/models.py index 43e2978ba8f..6944de714ba 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -8,7 +8,6 @@ from warnings import warn from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode from django.utils.datastructures import SortedDict -from django.core.exceptions import ImproperlyConfigured from util import ValidationError, ErrorList from forms import BaseForm, get_declared_fields diff --git a/django/forms/util.py b/django/forms/util.py index b3edf41adf7..3d80ad219fa 100644 --- a/django/forms/util.py +++ b/django/forms/util.py @@ -1,6 +1,5 @@ from django.utils.html import escape from django.utils.encoding import smart_unicode, StrAndUnicode, force_unicode -from django.utils.functional import Promise from django.utils.safestring import mark_safe def flatatt(attrs): diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index bfca46b3d57..8da9385f6c5 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -13,7 +13,7 @@ Usage: from django.utils.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR from django.utils.tzinfo import LocalTimezone -from django.utils.translation import string_concat, ugettext as _ +from django.utils.translation import ugettext as _ from django.utils.encoding import force_unicode from calendar import isleap, monthrange import re, time diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 33bb37b0ea8..c54e67610fd 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -1,9 +1,7 @@ import types import urllib import datetime - from django.utils.functional import Promise -from django.utils.safestring import SafeData, mark_safe class DjangoUnicodeDecodeError(UnicodeDecodeError): def __init__(self, obj, *args): diff --git a/django/views/generic/simple.py b/django/views/generic/simple.py index 9d7efdc6c4d..0a68b82a106 100644 --- a/django/views/generic/simple.py +++ b/django/views/generic/simple.py @@ -1,4 +1,3 @@ -from django.shortcuts import render_to_response from django.template import loader, RequestContext from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone