Skip to content

Commit 9b430c8

Browse files
committed
pep8
1 parent cd9b5c6 commit 9b430c8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

select_url_field/fields.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# Django < 1.9 and Python < 2.7
1313
from django.utils.importlib import import_module
1414

15+
1516
from select_url_field.choice_with_other import ChoiceWithOtherField
1617

18+
1719
class SelectURLField(models.CharField):
1820
description = _("URL")
1921

@@ -52,7 +54,6 @@ def formfield(self, **kwargs):
5254
required = not self.blank
5355
return ChoiceWithOtherField(choices=choices, required=required)
5456

55-
5657
def to_python(self, value):
5758
from django.conf import settings
5859
if value:
@@ -63,10 +64,13 @@ def to_python(self, value):
6364
value = domain_regex.sub('', value)
6465
return super(SelectURLField, self).to_python(value)
6566

67+
6668
# We need IxxyURLField so this is backwards compatible
6769
IxxyURLField = SelectURLField
6870

71+
6972
class SelectURLValidator(object):
73+
7074
code = 'invalid'
7175
regex = re.compile(r'(?:[/?]\S+)$', re.IGNORECASE)
7276

@@ -75,13 +79,14 @@ def __init__(self):
7579

7680
def __call__(self, value):
7781
try:
78-
# OK if it's a valid url
82+
# OK if it's a valid url
7983
self.url_validator(value)
8084
except ValidationError, e:
81-
# Not a valid url, see it's a path
85+
# Not a valid url, see it's a path
8286
if not self.regex.search(smart_unicode(value)):
8387
raise e
8488

89+
8590
class SelectURLFormField(forms.CharField):
8691
default_error_messages = {
8792
'invalid': _(u'Enter a valid URL.'),
@@ -91,6 +96,7 @@ def __init__(self, max_length=None, min_length=None, *args, **kwargs):
9196
super(SelectURLFormField, self).__init__(max_length, min_length, *args, **kwargs)
9297
self.validators.append(SelectURLValidator())
9398

99+
94100
try:
95101
from south.modelsinspector import add_introspection_rules
96102
add_introspection_rules([], ["^select_url_field\.fields\.IxxyURLField"])

0 commit comments

Comments
 (0)