Fixed imports to adhere to PEP 8 and stripped trailing whitespace.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6068 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7e57576ff7
commit
b0e173ae3f
|
@ -9,16 +9,17 @@ form field is required.
|
|||
"""
|
||||
|
||||
import urllib2
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy, ungettext
|
||||
from django.utils.functional import Promise, lazy
|
||||
from django.utils.encoding import force_unicode
|
||||
import re
|
||||
try:
|
||||
from decimal import Decimal, DecimalException
|
||||
except ImportError:
|
||||
from django.utils._decimal import Decimal, DecimalException # Python 2.3
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy, ungettext
|
||||
from django.utils.functional import Promise, lazy
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
_datere = r'\d{4}-\d{1,2}-\d{1,2}'
|
||||
_timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
|
||||
alnum_re = re.compile(r'^\w+$')
|
||||
|
@ -148,7 +149,7 @@ def _isValidDate(date_string):
|
|||
date(year, month, day)
|
||||
except ValueError, e:
|
||||
msg = _('Invalid date: %s') % _(str(e))
|
||||
raise ValidationError, msg
|
||||
raise ValidationError, msg
|
||||
|
||||
def isValidANSIDate(field_data, all_data):
|
||||
if not ansi_date_re.search(field_data):
|
||||
|
@ -251,7 +252,7 @@ def isExistingURL(field_data, all_data):
|
|||
raise ValidationError, _("The URL %s is a broken link.") % field_data
|
||||
except: # urllib2.URLError, httplib.InvalidURL, etc.
|
||||
raise ValidationError, _("The URL %s is a broken link.") % field_data
|
||||
|
||||
|
||||
def isValidUSState(field_data, all_data):
|
||||
"Checks that the given string is a valid two-letter U.S. state abbreviation"
|
||||
states = ['AA', 'AE', 'AK', 'AL', 'AP', 'AR', 'AS', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'FM', 'GA', 'GU', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MH', 'MI', 'MN', 'MO', 'MP', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'PR', 'PW', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VI', 'VT', 'WA', 'WI', 'WV', 'WY']
|
||||
|
@ -380,13 +381,13 @@ class NumberIsInRange(object):
|
|||
self.error_message = error_message
|
||||
|
||||
def __call__(self, field_data, all_data):
|
||||
# Try to make the value numeric. If this fails, we assume another
|
||||
# Try to make the value numeric. If this fails, we assume another
|
||||
# validator will catch the problem.
|
||||
try:
|
||||
val = float(field_data)
|
||||
except ValueError:
|
||||
return
|
||||
|
||||
|
||||
# Now validate
|
||||
if self.lower and self.upper and (val < self.lower or val > self.upper):
|
||||
raise ValidationError(self.error_message)
|
||||
|
|
|
@ -353,7 +353,7 @@ class UploadedFile(StrAndUnicode):
|
|||
def __init__(self, filename, content):
|
||||
self.filename = filename
|
||||
self.content = content
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
"""
|
||||
The unicode representation is the filename, so that the pre-database-insertion
|
||||
|
@ -396,7 +396,7 @@ class ImageField(FileField):
|
|||
except IOError: # Python Imaging Library doesn't recognize it as an image
|
||||
raise ValidationError(ugettext(u"Upload a valid image. The file you uploaded was either not an image or a corrupted image."))
|
||||
return f
|
||||
|
||||
|
||||
class URLField(RegexField):
|
||||
def __init__(self, max_length=None, min_length=None, verify_exists=False,
|
||||
validator_user_agent=URL_VALIDATOR_USER_AGENT, *args, **kwargs):
|
||||
|
@ -526,7 +526,7 @@ class ComboField(Field):
|
|||
class MultiValueField(Field):
|
||||
"""
|
||||
A Field that aggregates the logic of multiple Fields.
|
||||
|
||||
|
||||
Its clean() method takes a "decompressed" list of values, which are then
|
||||
cleaned into a single value according to self.fields. Each value in
|
||||
this list is cleaned by the corresponding field -- the first value is
|
||||
|
|
Loading…
Reference in New Issue