Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit b0e173ae3ff466f980846691a4be9f7c55a7405b 1 parent 7e57576
@gdub gdub authored
Showing with 12 additions and 11 deletions.
  1. +9 −8 django/core/validators.py
  2. +3 −3 django/newforms/fields.py
View
17 django/core/validators.py
@@ -9,16 +9,17 @@
"""
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 @@ def __init__(self, lower=None, upper=None, error_message=''):
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)
View
6 django/newforms/fields.py
@@ -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 @@ def clean(self, data):
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 @@ def clean(self, value):
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
Please sign in to comment.
Something went wrong with that request. Please try again.