diff --git a/django/contrib/localflavor/ar/forms.py b/django/contrib/localflavor/ar/forms.py index 36b7530e4c..1805839ce4 100644 --- a/django/contrib/localflavor/ar/forms.py +++ b/django/contrib/localflavor/ar/forms.py @@ -3,18 +3,21 @@ AR-specific Form helpers. """ -from django.forms import ValidationError +from __future__ import absolute_import + +from django.contrib.localflavor.ar.ar_provinces import PROVINCE_CHOICES from django.core.validators import EMPTY_VALUES +from django.forms import ValidationError from django.forms.fields import RegexField, CharField, Select from django.utils.translation import ugettext_lazy as _ + class ARProvinceSelect(Select): """ A Select widget that uses a list of Argentinean provinces/autonomous cities as its choices. """ def __init__(self, attrs=None): - from ar_provinces import PROVINCE_CHOICES super(ARProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) class ARPostalCodeField(RegexField): diff --git a/django/contrib/localflavor/au/forms.py b/django/contrib/localflavor/au/forms.py index db0bd78c9b..19df98dc33 100644 --- a/django/contrib/localflavor/au/forms.py +++ b/django/contrib/localflavor/au/forms.py @@ -1,14 +1,19 @@ """ Australian-specific Form helpers """ + +from __future__ import absolute_import + import re +from django.contrib.localflavor.au.au_states import STATE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ + PHONE_DIGITS_RE = re.compile(r'^(\d{10})$') class AUPostCodeField(RegexField): @@ -52,5 +57,4 @@ class AUStateSelect(Select): choices. """ def __init__(self, attrs=None): - from au_states import STATE_CHOICES super(AUStateSelect, self).__init__(attrs, choices=STATE_CHOICES) diff --git a/django/contrib/localflavor/be/forms.py b/django/contrib/localflavor/be/forms.py index 4e86d7e735..6166254ba3 100644 --- a/django/contrib/localflavor/be/forms.py +++ b/django/contrib/localflavor/be/forms.py @@ -1,13 +1,19 @@ """ Belgium-specific Form helpers """ + +from __future__ import absolute_import + +from django.contrib.localflavor.be.be_provinces import PROVINCE_CHOICES +from django.contrib.localflavor.be.be_regions import REGION_CHOICES from django.forms.fields import RegexField, Select from django.utils.translation import ugettext_lazy as _ + class BEPostalCodeField(RegexField): """ A form field that validates its input as a belgium postal code. - + Belgium postal code is a 4 digits string. The first digit indicates the province (except for the 3ddd numbers that are shared by the eastern part of Flemish Brabant and Limburg and the and 1ddd that @@ -28,14 +34,14 @@ class BEPhoneNumberField(RegexField): A form field that validates its input as a belgium phone number. Landlines have a seven-digit subscriber number and a one-digit area code, - while smaller cities have a six-digit subscriber number and a two-digit - area code. Cell phones have a six-digit subscriber number and a two-digit + while smaller cities have a six-digit subscriber number and a two-digit + area code. Cell phones have a six-digit subscriber number and a two-digit area code preceeded by the number 4. - 0d ddd dd dd, 0d/ddd.dd.dd, 0d.ddd.dd.dd, + 0d ddd dd dd, 0d/ddd.dd.dd, 0d.ddd.dd.dd, 0dddddddd - dialling a bigger city - 0dd dd dd dd, 0dd/dd.dd.dd, 0dd.dd.dd.dd, + 0dd dd dd dd, 0dd/dd.dd.dd, 0dd.dd.dd.dd, 0dddddddd - dialling a smaller city - 04dd ddd dd dd, 04dd/ddd.dd.dd, + 04dd ddd dd dd, 04dd/ddd.dd.dd, 04dd.ddd.dd.dd, 04ddddddddd - dialling a mobile number """ default_error_messages = { @@ -55,7 +61,6 @@ class BERegionSelect(Select): A Select widget that uses a list of belgium regions as its choices. """ def __init__(self, attrs=None): - from be_regions import REGION_CHOICES super(BERegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class BEProvinceSelect(Select): @@ -63,5 +68,4 @@ class BEProvinceSelect(Select): A Select widget that uses a list of belgium provinces as its choices. """ def __init__(self, attrs=None): - from be_provinces import PROVINCE_CHOICES super(BEProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) diff --git a/django/contrib/localflavor/br/forms.py b/django/contrib/localflavor/br/forms.py index 992a58fd45..88c7f2efcc 100644 --- a/django/contrib/localflavor/br/forms.py +++ b/django/contrib/localflavor/br/forms.py @@ -3,12 +3,17 @@ BR-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.br.br_states import STATE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, CharField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ -import re + phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4})[-\.]?(\d{4})$') @@ -42,7 +47,6 @@ class BRStateSelect(Select): as its choices. """ def __init__(self, attrs=None): - from br_states import STATE_CHOICES super(BRStateSelect, self).__init__(attrs, choices=STATE_CHOICES) class BRStateChoiceField(Field): @@ -58,7 +62,6 @@ class BRStateChoiceField(Field): initial=None, help_text=None): super(BRStateChoiceField, self).__init__(required, widget, label, initial, help_text) - from br_states import STATE_CHOICES self.widget.choices = STATE_CHOICES def clean(self, value): diff --git a/django/contrib/localflavor/ca/forms.py b/django/contrib/localflavor/ca/forms.py index ac393de397..a84a6d9557 100644 --- a/django/contrib/localflavor/ca/forms.py +++ b/django/contrib/localflavor/ca/forms.py @@ -2,12 +2,17 @@ Canada-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.ca.ca_provinces import PROVINCE_CHOICES, PROVINCES_NORMALIZED from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, CharField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ -import re + phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$') sin_re = re.compile(r"^(\d{3})-(\d{3})-(\d{3})$") @@ -66,7 +71,6 @@ class CAProvinceField(Field): } def clean(self, value): - from ca_provinces import PROVINCES_NORMALIZED super(CAProvinceField, self).clean(value) if value in EMPTY_VALUES: return u'' @@ -87,7 +91,6 @@ class CAProvinceSelect(Select): territories as its choices. """ def __init__(self, attrs=None): - from ca_provinces import PROVINCE_CHOICES # relative import super(CAProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) class CASocialInsuranceNumberField(Field): diff --git a/django/contrib/localflavor/ch/forms.py b/django/contrib/localflavor/ch/forms.py index d0c105dcbf..9875c95fb3 100644 --- a/django/contrib/localflavor/ch/forms.py +++ b/django/contrib/localflavor/ch/forms.py @@ -2,12 +2,17 @@ Swiss-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.ch.ch_states import STATE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ -import re + id_re = re.compile(r"^(?P\w{8})(?P(\d{1}|<))(?P\d{1})$") phone_digits_re = re.compile(r'^0([1-9]{1})\d{8}$') @@ -47,7 +52,6 @@ class CHStateSelect(Select): A Select widget that uses a list of CH states as its choices. """ def __init__(self, attrs=None): - from ch_states import STATE_CHOICES # relative import super(CHStateSelect, self).__init__(attrs, choices=STATE_CHOICES) class CHIdentityCardNumberField(Field): diff --git a/django/contrib/localflavor/cl/forms.py b/django/contrib/localflavor/cl/forms.py index 23a2209a10..7a9aa2da8c 100644 --- a/django/contrib/localflavor/cl/forms.py +++ b/django/contrib/localflavor/cl/forms.py @@ -2,6 +2,9 @@ Chile specific form helpers. """ +from __future__ import absolute_import + +from django.contrib.localflavor.cl.cl_regions import REGION_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import RegexField, Select @@ -15,7 +18,6 @@ class CLRegionSelect(Select): as its choices. """ def __init__(self, attrs=None): - from cl_regions import REGION_CHOICES super(CLRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class CLRutField(RegexField): diff --git a/django/contrib/localflavor/cn/forms.py b/django/contrib/localflavor/cn/forms.py index 3d8d45c53e..af92ba06ec 100644 --- a/django/contrib/localflavor/cn/forms.py +++ b/django/contrib/localflavor/cn/forms.py @@ -3,8 +3,11 @@ """ Chinese-specific form helpers """ +from __future__ import absolute_import + import re +from django.contrib.localflavor.cn.cn_provinces import CN_PROVINCE_CHOICES from django.forms import ValidationError from django.forms.fields import CharField, RegexField, Select from django.utils.translation import ugettext_lazy as _ @@ -67,7 +70,6 @@ class CNProvinceSelect(Select): A select widget with list of Chinese provinces as choices. """ def __init__(self, attrs=None): - from cn_provinces import CN_PROVINCE_CHOICES super(CNProvinceSelect, self).__init__( attrs, choices=CN_PROVINCE_CHOICES, ) diff --git a/django/contrib/localflavor/co/forms.py b/django/contrib/localflavor/co/forms.py index 41e77b3a87..cdd151e0df 100644 --- a/django/contrib/localflavor/co/forms.py +++ b/django/contrib/localflavor/co/forms.py @@ -2,12 +2,15 @@ Colombian-specific form helpers. """ +from __future__ import absolute_import + +from django.contrib.localflavor.co.co_departments import DEPARTMENT_CHOICES from django.forms.fields import Select + class CODepartmentSelect(Select): """ A Select widget that uses a list of Colombian states as its choices. """ def __init__(self, attrs=None): - from co_departments import DEPARTMENT_CHOICES super(CODepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES) diff --git a/django/contrib/localflavor/cz/forms.py b/django/contrib/localflavor/cz/forms.py index 402cb3e000..699f395ad7 100644 --- a/django/contrib/localflavor/cz/forms.py +++ b/django/contrib/localflavor/cz/forms.py @@ -2,11 +2,16 @@ Czech-specific form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.cz.cz_regions import REGION_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Select, RegexField, Field from django.utils.translation import ugettext_lazy as _ -import re + birth_number = re.compile(r'^(?P\d{6})/?(?P\d{3,4})$') ic_number = re.compile(r'^(?P\d{7})(?P\d)$') @@ -16,7 +21,6 @@ class CZRegionSelect(Select): A select widget widget with list of Czech regions as choices. """ def __init__(self, attrs=None): - from cz_regions import REGION_CHOICES super(CZRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class CZPostalCodeField(RegexField): diff --git a/django/contrib/localflavor/de/forms.py b/django/contrib/localflavor/de/forms.py index b467c2e287..80b6248ed4 100644 --- a/django/contrib/localflavor/de/forms.py +++ b/django/contrib/localflavor/de/forms.py @@ -2,11 +2,16 @@ DE-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.de.de_states import STATE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.translation import ugettext_lazy as _ -import re + id_re = re.compile(r"^(?P\d{10})(?P\w{1,3})[-\ ]?(?P\d{7})[-\ ]?(?P\d{7})[-\ ]?(?P\d{1})$") @@ -23,7 +28,6 @@ class DEStateSelect(Select): A Select widget that uses a list of DE states as its choices. """ def __init__(self, attrs=None): - from de_states import STATE_CHOICES super(DEStateSelect, self).__init__(attrs, choices=STATE_CHOICES) class DEIdentityCardNumberField(Field): diff --git a/django/contrib/localflavor/ec/forms.py b/django/contrib/localflavor/ec/forms.py index d98b36c2cc..d28728b940 100644 --- a/django/contrib/localflavor/ec/forms.py +++ b/django/contrib/localflavor/ec/forms.py @@ -2,6 +2,9 @@ Ecuador-specific form helpers. """ +from __future__ import absolute_import + +from django.contrib.localflavor.ec.ec_provinces import PROVINCE_CHOICES from django.forms.fields import Select class ECProvinceSelect(Select): @@ -9,5 +12,4 @@ class ECProvinceSelect(Select): A Select widget that uses a list of Ecuador provinces as its choices. """ def __init__(self, attrs=None): - from ec_provinces import PROVINCE_CHOICES super(ECProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) diff --git a/django/contrib/localflavor/es/forms.py b/django/contrib/localflavor/es/forms.py index 42e8e9df2c..fe237270f5 100644 --- a/django/contrib/localflavor/es/forms.py +++ b/django/contrib/localflavor/es/forms.py @@ -3,11 +3,17 @@ Spanish-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.es.es_provinces import PROVINCE_CHOICES +from django.contrib.localflavor.es.es_regions import REGION_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import RegexField, Select from django.utils.translation import ugettext_lazy as _ -import re + class ESPostalCodeField(RegexField): """ @@ -166,7 +172,6 @@ class ESRegionSelect(Select): A Select widget that uses a list of spanish regions as its choices. """ def __init__(self, attrs=None): - from es_regions import REGION_CHOICES super(ESRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class ESProvinceSelect(Select): @@ -174,7 +179,6 @@ class ESProvinceSelect(Select): A Select widget that uses a list of spanish provinces as its choices. """ def __init__(self, attrs=None): - from es_provinces import PROVINCE_CHOICES super(ESProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) diff --git a/django/contrib/localflavor/fi/forms.py b/django/contrib/localflavor/fi/forms.py index 7556173ece..ddc3b48c54 100644 --- a/django/contrib/localflavor/fi/forms.py +++ b/django/contrib/localflavor/fi/forms.py @@ -2,12 +2,17 @@ FI-specific Form helpers """ +from __future__ import absolute_import + import re + +from django.contrib.localflavor.fi.fi_municipalities import MUNICIPALITY_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.translation import ugettext_lazy as _ + class FIZipCodeField(RegexField): default_error_messages = { 'invalid': _('Enter a zip code in the format XXXXX.'), @@ -21,7 +26,6 @@ class FIMunicipalitySelect(Select): A Select widget that uses a list of Finnish municipalities as its choices. """ def __init__(self, attrs=None): - from fi_municipalities import MUNICIPALITY_CHOICES super(FIMunicipalitySelect, self).__init__(attrs, choices=MUNICIPALITY_CHOICES) class FISocialSecurityNumber(Field): diff --git a/django/contrib/localflavor/fr/forms.py b/django/contrib/localflavor/fr/forms.py index 54f933a31d..53ad7c6c1e 100644 --- a/django/contrib/localflavor/fr/forms.py +++ b/django/contrib/localflavor/fr/forms.py @@ -1,13 +1,17 @@ """ FR-specific Form helpers """ +from __future__ import absolute_import +import re + +from django.contrib.localflavor.fr.fr_department import DEPARTMENT_ASCII_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ -import re + phone_digits_re = re.compile(r'^0\d(\s|\.)?(\d{2}(\s|\.)?){3}\d{2}$') @@ -46,6 +50,5 @@ class FRDepartmentSelect(Select): A Select widget that uses a list of FR departments as its choices. """ def __init__(self, attrs=None): - from fr_department import DEPARTMENT_ASCII_CHOICES super(FRDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ASCII_CHOICES) diff --git a/django/contrib/localflavor/gb/forms.py b/django/contrib/localflavor/gb/forms.py index 0f7d91a4a9..a6658578b1 100644 --- a/django/contrib/localflavor/gb/forms.py +++ b/django/contrib/localflavor/gb/forms.py @@ -2,12 +2,16 @@ GB-specific Form helpers """ +from __future__ import absolute_import + import re +from django.contrib.localflavor.gb.gb_regions import GB_NATIONS_CHOICES, GB_REGION_CHOICES from django.forms.fields import CharField, Select from django.forms import ValidationError from django.utils.translation import ugettext_lazy as _ + class GBPostcodeField(CharField): """ A form field that validates its input is a UK postcode. @@ -41,7 +45,6 @@ class GBCountySelect(Select): A Select widget that uses a list of UK Counties/Regions as its choices. """ def __init__(self, attrs=None): - from gb_regions import GB_REGION_CHOICES super(GBCountySelect, self).__init__(attrs, choices=GB_REGION_CHOICES) class GBNationSelect(Select): @@ -49,5 +52,4 @@ class GBNationSelect(Select): A Select widget that uses a list of UK Nations as its choices. """ def __init__(self, attrs=None): - from gb_regions import GB_NATIONS_CHOICES super(GBNationSelect, self).__init__(attrs, choices=GB_NATIONS_CHOICES) diff --git a/django/contrib/localflavor/hr/forms.py b/django/contrib/localflavor/hr/forms.py index 6d50b6335f..0ff283d6c8 100644 --- a/django/contrib/localflavor/hr/forms.py +++ b/django/contrib/localflavor/hr/forms.py @@ -2,13 +2,19 @@ """ HR-specific Form helpers """ +from __future__ import absolute_import + import re -from django.forms.fields import Field, Select, RegexField +from django.contrib.localflavor.hr.hr_choices import ( + HR_LICENSE_PLATE_PREFIX_CHOICES, HR_COUNTY_CHOICES, + HR_PHONE_NUMBER_PREFIX_CHOICES) from django.core.validators import EMPTY_VALUES from django.forms import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.forms.fields import Field, Select, RegexField from django.utils.encoding import smart_unicode +from django.utils.translation import ugettext_lazy as _ + jmbg_re = re.compile(r'^(?P
\d{2})(?P\d{2})(?P\d{3})' + \ r'(?P\d{2})(?P\d{3})(?P\d{1})$') @@ -26,7 +32,6 @@ class HRCountySelect(Select): """ def __init__(self, attrs=None): - from hr_choices import HR_COUNTY_CHOICES super(HRCountySelect, self).__init__(attrs, choices=HR_COUNTY_CHOICES) @@ -37,7 +42,6 @@ class HRLicensePlatePrefixSelect(Select): """ def __init__(self, attrs=None): - from hr_choices import HR_LICENSE_PLATE_PREFIX_CHOICES super(HRLicensePlatePrefixSelect, self).__init__(attrs, choices=HR_LICENSE_PLATE_PREFIX_CHOICES) @@ -49,7 +53,6 @@ class HRPhoneNumberPrefixSelect(Select): """ def __init__(self, attrs=None): - from hr_choices import HR_PHONE_NUMBER_PREFIX_CHOICES super(HRPhoneNumberPrefixSelect, self).__init__(attrs, choices=HR_PHONE_NUMBER_PREFIX_CHOICES) @@ -163,7 +166,6 @@ class HRLicensePlateField(Field): raise ValidationError(self.error_messages['invalid']) # Make sure the prefix is in the list of known codes. - from hr_choices import HR_LICENSE_PLATE_PREFIX_CHOICES prefix = matches.group('prefix') if prefix not in [choice[0] for choice in HR_LICENSE_PLATE_PREFIX_CHOICES]: raise ValidationError(self.error_messages['area']) @@ -230,7 +232,6 @@ class HRPhoneNumberField(Field): raise ValidationError(self.error_messages['invalid']) # Make sure the prefix is in the list of known codes. - from hr_choices import HR_PHONE_NUMBER_PREFIX_CHOICES prefix = matches.group('prefix') number = matches.group('number') if prefix[0] == '1': diff --git a/django/contrib/localflavor/id/forms.py b/django/contrib/localflavor/id/forms.py index 834e588749..e2419f3b1c 100644 --- a/django/contrib/localflavor/id/forms.py +++ b/django/contrib/localflavor/id/forms.py @@ -2,15 +2,19 @@ ID-specific Form helpers """ +from __future__ import absolute_import + import re import time from django.core.validators import EMPTY_VALUES +from django.contrib.localflavor.id.id_choices import PROVINCE_CHOICES, LICENSE_PLATE_PREFIX_CHOICES from django.forms import ValidationError from django.forms.fields import Field, Select from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode + postcode_re = re.compile(r'^[1-9]\d{4}$') phone_re = re.compile(r'^(\+62|0)[2-9]\d{7,10}$') plate_re = re.compile(r'^(?P[A-Z]{1,2}) ' + \ @@ -54,7 +58,6 @@ class IDProvinceSelect(Select): """ def __init__(self, attrs=None): - from id_choices import PROVINCE_CHOICES super(IDProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) @@ -90,7 +93,6 @@ class IDLicensePlatePrefixSelect(Select): """ def __init__(self, attrs=None): - from id_choices import LICENSE_PLATE_PREFIX_CHOICES super(IDLicensePlatePrefixSelect, self).__init__(attrs, choices=LICENSE_PLATE_PREFIX_CHOICES) @@ -120,7 +122,6 @@ class IDLicensePlateField(Field): raise ValidationError(self.error_messages['invalid']) # Make sure prefix is in the list of known codes. - from id_choices import LICENSE_PLATE_PREFIX_CHOICES prefix = matches.group('prefix') if prefix not in [choice[0] for choice in LICENSE_PLATE_PREFIX_CHOICES]: raise ValidationError(self.error_messages['invalid']) diff --git a/django/contrib/localflavor/ie/forms.py b/django/contrib/localflavor/ie/forms.py index 2cfd2f2bcc..cb401019c2 100644 --- a/django/contrib/localflavor/ie/forms.py +++ b/django/contrib/localflavor/ie/forms.py @@ -2,12 +2,15 @@ UK-specific Form helpers """ +from __future__ import absolute_import + +from django.contrib.localflavor.ie.ie_counties import IE_COUNTY_CHOICES from django.forms.fields import Select + class IECountySelect(Select): """ A Select widget that uses a list of Irish Counties as its choices. """ def __init__(self, attrs=None): - from ie_counties import IE_COUNTY_CHOICES super(IECountySelect, self).__init__(attrs, choices=IE_COUNTY_CHOICES) diff --git a/django/contrib/localflavor/in_/forms.py b/django/contrib/localflavor/in_/forms.py index 50db790143..11011e1df2 100644 --- a/django/contrib/localflavor/in_/forms.py +++ b/django/contrib/localflavor/in_/forms.py @@ -1,14 +1,19 @@ """ India-specific Form helpers. """ + +from __future__ import absolute_import + import re +from django.contrib.localflavor.in_.in_states import STATES_NORMALIZED, STATE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, CharField, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ + phone_digits_re = re.compile(r""" ( (?P # the std-code group @@ -60,7 +65,6 @@ class INStateField(Field): } def clean(self, value): - from in_states import STATES_NORMALIZED super(INStateField, self).clean(value) if value in EMPTY_VALUES: return u'' @@ -82,7 +86,6 @@ class INStateSelect(Select): choices. """ def __init__(self, attrs=None): - from in_states import STATE_CHOICES super(INStateSelect, self).__init__(attrs, choices=STATE_CHOICES) diff --git a/django/contrib/localflavor/is_/forms.py b/django/contrib/localflavor/is_/forms.py index d651cac33f..ca7bd5004e 100644 --- a/django/contrib/localflavor/is_/forms.py +++ b/django/contrib/localflavor/is_/forms.py @@ -2,12 +2,16 @@ Iceland specific form helpers. """ +from __future__ import absolute_import + +from django.contrib.localflavor.is_.is_postalcodes import IS_POSTALCODES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import RegexField from django.forms.widgets import Select -from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode +from django.utils.translation import ugettext_lazy as _ + class ISIdNumberField(RegexField): """ @@ -78,6 +82,5 @@ class ISPostalCodeSelect(Select): A Select widget that uses a list of Icelandic postal codes as its choices. """ def __init__(self, attrs=None): - from is_postalcodes import IS_POSTALCODES super(ISPostalCodeSelect, self).__init__(attrs, choices=IS_POSTALCODES) diff --git a/django/contrib/localflavor/it/forms.py b/django/contrib/localflavor/it/forms.py index 460ebffaa1..0060b486bd 100644 --- a/django/contrib/localflavor/it/forms.py +++ b/django/contrib/localflavor/it/forms.py @@ -2,13 +2,19 @@ IT-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.it.it_province import PROVINCE_CHOICES +from django.contrib.localflavor.it.it_region import REGION_CHOICES +from django.contrib.localflavor.it.util import ssn_check_digit, vat_number_check_digit from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode -from django.contrib.localflavor.it.util import ssn_check_digit, vat_number_check_digit -import re + class ITZipCodeField(RegexField): default_error_messages = { @@ -23,7 +29,6 @@ class ITRegionSelect(Select): A Select widget that uses a list of IT regions as its choices. """ def __init__(self, attrs=None): - from it_region import REGION_CHOICES super(ITRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class ITProvinceSelect(Select): @@ -31,7 +36,6 @@ class ITProvinceSelect(Select): A Select widget that uses a list of IT provinces as its choices. """ def __init__(self, attrs=None): - from it_province import PROVINCE_CHOICES super(ITProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) class ITSocialSecurityNumberField(RegexField): diff --git a/django/contrib/localflavor/jp/forms.py b/django/contrib/localflavor/jp/forms.py index 11dc6e81c0..2529364d5a 100644 --- a/django/contrib/localflavor/jp/forms.py +++ b/django/contrib/localflavor/jp/forms.py @@ -2,8 +2,12 @@ JP-specific Form helpers """ -from django.utils.translation import ugettext_lazy as _ +from __future__ import absolute_import + +from django.contrib.localflavor.jp.jp_prefectures import JP_PREFECTURES from django.forms.fields import RegexField, Select +from django.utils.translation import ugettext_lazy as _ + class JPPostalCodeField(RegexField): """ @@ -32,5 +36,4 @@ class JPPrefectureSelect(Select): A Select widget that uses a list of Japanese prefectures as its choices. """ def __init__(self, attrs=None): - from jp_prefectures import JP_PREFECTURES super(JPPrefectureSelect, self).__init__(attrs, choices=JP_PREFECTURES) diff --git a/django/contrib/localflavor/mk/forms.py b/django/contrib/localflavor/mk/forms.py index 0548de3a40..33dbfc71a0 100644 --- a/django/contrib/localflavor/mk/forms.py +++ b/django/contrib/localflavor/mk/forms.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import datetime from django.core.validators import EMPTY_VALUES @@ -5,7 +7,7 @@ from django.forms import ValidationError from django.forms.fields import RegexField, Select from django.utils.translation import ugettext_lazy as _ -from mk_choices import MK_MUNICIPALITIES +from django.contrib.localflavor.mk.mk_choices import MK_MUNICIPALITIES class MKIdentityCardNumberField(RegexField): diff --git a/django/contrib/localflavor/nl/forms.py b/django/contrib/localflavor/nl/forms.py index 997c28f609..66900808c2 100644 --- a/django/contrib/localflavor/nl/forms.py +++ b/django/contrib/localflavor/nl/forms.py @@ -2,13 +2,17 @@ NL-specific Form helpers """ +from __future__ import absolute_import + import re +from django.contrib.localflavor.nl.nl_provinces import PROVINCE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, Select -from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode +from django.utils.translation import ugettext_lazy as _ + pc_re = re.compile('^\d{4}[A-Z]{2}$') sofi_re = re.compile('^\d{9}$') @@ -42,7 +46,6 @@ class NLProvinceSelect(Select): choices. """ def __init__(self, attrs=None): - from nl_provinces import PROVINCE_CHOICES super(NLProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) class NLPhoneNumberField(Field): diff --git a/django/contrib/localflavor/no/forms.py b/django/contrib/localflavor/no/forms.py index 930cc176d6..3e5e58bd1c 100644 --- a/django/contrib/localflavor/no/forms.py +++ b/django/contrib/localflavor/no/forms.py @@ -2,13 +2,18 @@ Norwegian-specific Form helpers """ +from __future__ import absolute_import + import re import datetime + +from django.contrib.localflavor.no.no_municipalities import MUNICIPALITY_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select from django.utils.translation import ugettext_lazy as _ + class NOZipCodeField(RegexField): default_error_messages = { 'invalid': _('Enter a zip code in the format XXXX.'), @@ -24,7 +29,6 @@ class NOMunicipalitySelect(Select): as its choices. """ def __init__(self, attrs=None): - from no_municipalities import MUNICIPALITY_CHOICES super(NOMunicipalitySelect, self).__init__(attrs, choices=MUNICIPALITY_CHOICES) class NOSocialSecurityNumber(Field): diff --git a/django/contrib/localflavor/pe/forms.py b/django/contrib/localflavor/pe/forms.py index c1b41957fa..0eca2b8ac7 100644 --- a/django/contrib/localflavor/pe/forms.py +++ b/django/contrib/localflavor/pe/forms.py @@ -3,17 +3,20 @@ PE-specific Form helpers. """ +from __future__ import absolute_import + +from django.contrib.localflavor.pe.pe_region import REGION_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import RegexField, CharField, Select from django.utils.translation import ugettext_lazy as _ + class PERegionSelect(Select): """ A Select widget that uses a list of Peruvian Regions as its choices. """ def __init__(self, attrs=None): - from pe_region import REGION_CHOICES super(PERegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class PEDNIField(CharField): diff --git a/django/contrib/localflavor/pl/forms.py b/django/contrib/localflavor/pl/forms.py index 8b4d2f4aaa..ffa9ec4087 100644 --- a/django/contrib/localflavor/pl/forms.py +++ b/django/contrib/localflavor/pl/forms.py @@ -2,19 +2,23 @@ Polish-specific form helpers """ +from __future__ import absolute_import + import re +from django.contrib.localflavor.pl.pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES +from django.contrib.localflavor.pl.pl_voivodeships import VOIVODESHIP_CHOICES +from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Select, RegexField from django.utils.translation import ugettext_lazy as _ -from django.core.validators import EMPTY_VALUES + class PLProvinceSelect(Select): """ A select widget with list of Polish administrative provinces as choices. """ def __init__(self, attrs=None): - from pl_voivodeships import VOIVODESHIP_CHOICES super(PLProvinceSelect, self).__init__(attrs, choices=VOIVODESHIP_CHOICES) class PLCountySelect(Select): @@ -22,7 +26,6 @@ class PLCountySelect(Select): A select widget with list of Polish administrative units as choices. """ def __init__(self, attrs=None): - from pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES super(PLCountySelect, self).__init__(attrs, choices=ADMINISTRATIVE_UNIT_CHOICES) class PLPESELField(RegexField): diff --git a/django/contrib/localflavor/py/forms.py b/django/contrib/localflavor/py/forms.py index 85ddffd82f..8cb5faa80f 100644 --- a/django/contrib/localflavor/py/forms.py +++ b/django/contrib/localflavor/py/forms.py @@ -1,14 +1,18 @@ """ PY-specific Form helpers. """ + +from __future__ import absolute_import + +from django.contrib.localflavor.py.py_department import DEPARTMENT_CHOICES, DEPARTMENT_ROMAN_CHOICES from django.forms.fields import Select + class PyDepartmentSelect(Select): """ A Select widget with a list of Paraguayan departments as choices. """ def __init__(self, attrs=None): - from py_department import DEPARTMENT_CHOICES super(PyDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES) @@ -17,5 +21,4 @@ class PyNumberedDepartmentSelect(Select): A Select widget with a roman numbered list of Paraguayan departments as choices. """ def __init__(self, attrs=None): - from py_department import DEPARTMENT_ROMAN_CHOICES super(PyNumberedDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ROMAN_CHOICES) diff --git a/django/contrib/localflavor/ro/forms.py b/django/contrib/localflavor/ro/forms.py index 1121f8ea04..d6aadf7ba5 100644 --- a/django/contrib/localflavor/ro/forms.py +++ b/django/contrib/localflavor/ro/forms.py @@ -2,10 +2,14 @@ """ Romanian specific form helpers. """ +from __future__ import absolute_import + +from django.contrib.localflavor.ro.ro_counties import COUNTIES_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError, Field, RegexField, Select from django.utils.translation import ugettext_lazy as _ + class ROCIFField(RegexField): """ A Romanian fiscal identity code (CIF) field @@ -100,7 +104,6 @@ class ROCountyField(Field): } def clean(self, value): - from ro_counties import COUNTIES_CHOICES super(ROCountyField, self).clean(value) if value in EMPTY_VALUES: return u'' @@ -127,7 +130,6 @@ class ROCountySelect(Select): choices. """ def __init__(self, attrs=None): - from ro_counties import COUNTIES_CHOICES super(ROCountySelect, self).__init__(attrs, choices=COUNTIES_CHOICES) class ROIBANField(RegexField): diff --git a/django/contrib/localflavor/ru/forms.py b/django/contrib/localflavor/ru/forms.py index a8662b5e47..d01f5a1e3b 100644 --- a/django/contrib/localflavor/ru/forms.py +++ b/django/contrib/localflavor/ru/forms.py @@ -1,20 +1,22 @@ """ Russian-specific forms helpers """ +from __future__ import absolute_import + import re +from django.contrib.localflavor.ru.ru_regions import RU_COUNTY_CHOICES, RU_REGIONS_CHOICES from django.forms.fields import RegexField, Select from django.utils.translation import ugettext_lazy as _ -phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$') +phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$') class RUCountySelect(Select): """ A Select widget that uses a list of Russian Counties as its choices. """ def __init__(self, attrs=None): - from ru_regions import RU_COUNTY_CHOICES super(RUCountySelect, self).__init__(attrs, choices=RU_COUNTY_CHOICES) @@ -23,7 +25,6 @@ class RURegionSelect(Select): A Select widget that uses a list of Russian Regions as its choices. """ def __init__(self, attrs=None): - from ru_regions import RU_REGIONS_CHOICES super(RURegionSelect, self).__init__(attrs, choices=RU_REGIONS_CHOICES) diff --git a/django/contrib/localflavor/se/forms.py b/django/contrib/localflavor/se/forms.py index 951f4f8d55..5c4e2325a9 100644 --- a/django/contrib/localflavor/se/forms.py +++ b/django/contrib/localflavor/se/forms.py @@ -2,14 +2,19 @@ """ Swedish specific Form helpers """ +from __future__ import absolute_import + import re + from django import forms from django.utils.translation import ugettext_lazy as _ from django.core.validators import EMPTY_VALUES +from django.contrib.localflavor.se.se_counties import COUNTY_CHOICES from django.contrib.localflavor.se.utils import (id_number_checksum, validate_id_birthday, format_personal_id_number, valid_organisation, format_organisation_number) + __all__ = ('SECountySelect', 'SEOrganisationNumberField', 'SEPersonalIdentityNumberField', 'SEPostalCodeField') @@ -26,7 +31,6 @@ class SECountySelect(forms.Select): """ def __init__(self, attrs=None): - from se_counties import COUNTY_CHOICES super(SECountySelect, self).__init__(attrs=attrs, choices=COUNTY_CHOICES) @@ -52,20 +56,20 @@ class SEOrganisationNumberField(forms.CharField): def clean(self, value): value = super(SEOrganisationNumberField, self).clean(value) - + if value in EMPTY_VALUES: return u'' - + match = SWEDISH_ID_NUMBER.match(value) if not match: raise forms.ValidationError(self.error_messages['invalid']) gd = match.groupdict() - - # Compare the calculated value with the checksum + + # Compare the calculated value with the checksum if id_number_checksum(gd) != int(gd['checksum']): raise forms.ValidationError(self.error_messages['invalid']) - + # First: check if this is a real organisation_number if valid_organisation(gd): return format_organisation_number(gd) @@ -88,7 +92,7 @@ class SEPersonalIdentityNumberField(forms.CharField): A + indicates that the person is older than 100 years, which will be taken into consideration when the date is validated. - + The checksum will be calculated and checked. The birth date is checked to be a valid date. @@ -113,14 +117,14 @@ class SEPersonalIdentityNumberField(forms.CharField): if value in EMPTY_VALUES: return u'' - + match = SWEDISH_ID_NUMBER.match(value) if match is None: raise forms.ValidationError(self.error_messages['invalid']) gd = match.groupdict() - - # compare the calculated value with the checksum + + # compare the calculated value with the checksum if id_number_checksum(gd) != int(gd['checksum']): raise forms.ValidationError(self.error_messages['invalid']) @@ -130,10 +134,10 @@ class SEPersonalIdentityNumberField(forms.CharField): except ValueError: raise forms.ValidationError(self.error_messages['invalid']) - # make sure that co-ordination numbers do not pass if not allowed + # make sure that co-ordination numbers do not pass if not allowed if not self.coordination_number and int(gd['day']) > 60: raise forms.ValidationError(self.error_messages['coordination_number']) - + return format_personal_id_number(birth_day, gd) @@ -143,7 +147,7 @@ class SEPostalCodeField(forms.RegexField): Valid codes consist of five digits (XXXXX). The number can optionally be formatted with a space after the third digit (XXX XX). - The cleaned value will never contain the space. + The cleaned value will never contain the space. """ default_error_messages = { diff --git a/django/contrib/localflavor/si/forms.py b/django/contrib/localflavor/si/forms.py index 103b142213..f1188dd222 100644 --- a/django/contrib/localflavor/si/forms.py +++ b/django/contrib/localflavor/si/forms.py @@ -2,12 +2,15 @@ Slovenian specific form helpers. """ +from __future__ import absolute_import + import datetime import re -from django.forms.fields import CharField, Select, ChoiceField +from django.contrib.localflavor.si.si_postalcodes import SI_POSTALCODES_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError +from django.forms.fields import CharField, Select, ChoiceField from django.utils.translation import ugettext_lazy as _ @@ -116,7 +119,6 @@ class SIPostalCodeField(ChoiceField): """ def __init__(self, *args, **kwargs): - from si_postalcodes import SI_POSTALCODES_CHOICES kwargs.setdefault('choices', SI_POSTALCODES_CHOICES) super(SIPostalCodeField, self).__init__(*args, **kwargs) @@ -125,7 +127,6 @@ class SIPostalCodeSelect(Select): """A Select widget that uses Slovenian postal codes as its choices. """ def __init__(self, attrs=None): - from si_postalcodes import SI_POSTALCODES_CHOICES super(SIPostalCodeSelect, self).__init__(attrs, choices=SI_POSTALCODES_CHOICES) diff --git a/django/contrib/localflavor/sk/forms.py b/django/contrib/localflavor/sk/forms.py index 389e7b7594..83afeb41b9 100644 --- a/django/contrib/localflavor/sk/forms.py +++ b/django/contrib/localflavor/sk/forms.py @@ -2,15 +2,19 @@ Slovak-specific form helpers """ +from __future__ import absolute_import + +from django.contrib.localflavor.sk.sk_districts import DISTRICT_CHOICES +from django.contrib.localflavor.sk.sk_regions import REGION_CHOICES from django.forms.fields import Select, RegexField from django.utils.translation import ugettext_lazy as _ + class SKRegionSelect(Select): """ A select widget widget with list of Slovak regions as choices. """ def __init__(self, attrs=None): - from sk_regions import REGION_CHOICES super(SKRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class SKDistrictSelect(Select): @@ -18,7 +22,6 @@ class SKDistrictSelect(Select): A select widget with list of Slovak districts as choices. """ def __init__(self, attrs=None): - from sk_districts import DISTRICT_CHOICES super(SKDistrictSelect, self).__init__(attrs, choices=DISTRICT_CHOICES) class SKPostalCodeField(RegexField): diff --git a/django/contrib/localflavor/tr/forms.py b/django/contrib/localflavor/tr/forms.py index d2ae9bb804..77a2b41986 100644 --- a/django/contrib/localflavor/tr/forms.py +++ b/django/contrib/localflavor/tr/forms.py @@ -2,12 +2,17 @@ TR-specific Form helpers """ +from __future__ import absolute_import + +import re + +from django.contrib.localflavor.tr.tr_provinces import PROVINCE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, RegexField, Select, CharField from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ -import re + phone_digits_re = re.compile(r'^(\+90|0)? ?(([1-9]\d{2})|\([1-9]\d{2}\)) ?([2-9]\d{2} ?\d{2} ?\d{2})$') @@ -87,5 +92,4 @@ class TRProvinceSelect(Select): A Select widget that uses a list of provinces in Turkey as its choices. """ def __init__(self, attrs=None): - from tr_provinces import PROVINCE_CHOICES super(TRProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) diff --git a/django/contrib/messages/__init__.py b/django/contrib/messages/__init__.py index 36a990cc6a..68a53d996f 100644 --- a/django/contrib/messages/__init__.py +++ b/django/contrib/messages/__init__.py @@ -1,2 +1,4 @@ -from api import * -from constants import * +from __future__ import absolute_import + +from django.contrib.messages.api import * +from django.contrib.messages.constants import * diff --git a/django/db/models/sql/__init__.py b/django/db/models/sql/__init__.py index c07f2b7b23..df5b74e326 100644 --- a/django/db/models/sql/__init__.py +++ b/django/db/models/sql/__init__.py @@ -1,7 +1,9 @@ -from query import * -from subqueries import * +from __future__ import absolute_import + from django.db.models.sql.datastructures import EmptyResultSet +from django.db.models.sql.subqueries import * +from django.db.models.sql.query import * from django.db.models.sql.where import AND, OR -__all__ = ['Query', 'AND', 'OR', 'EmptyResultSet'] +__all__ = ['Query', 'AND', 'OR', 'EmptyResultSet'] diff --git a/django/forms/__init__.py b/django/forms/__init__.py index dc8b5212c4..ec37a475e3 100644 --- a/django/forms/__init__.py +++ b/django/forms/__init__.py @@ -10,8 +10,10 @@ TODO: "This form field requires foo.js" and form.js_includes() """ +from __future__ import absolute_import + from django.core.exceptions import ValidationError -from widgets import * -from fields import * -from forms import * -from models import * +from django.forms.fields import * +from django.forms.forms import * +from django.forms.models import * +from django.forms.widgets import * diff --git a/django/forms/extras/__init__.py b/django/forms/extras/__init__.py index a7f6a9b3f6..d801e4fa80 100644 --- a/django/forms/extras/__init__.py +++ b/django/forms/extras/__init__.py @@ -1 +1,3 @@ -from widgets import * +from __future__ import absolute_import + +from django.forms.extras.widgets import * diff --git a/django/http/__init__.py b/django/http/__init__.py index c6bf2f174f..fee3f04cd3 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import datetime import os import re @@ -109,14 +111,14 @@ class CompatCookie(SimpleCookie): warnings.warn("CompatCookie is deprecated, use django.http.SimpleCookie instead.", DeprecationWarning) -from django.utils.datastructures import MultiValueDict, ImmutableList -from django.utils.encoding import smart_str, iri_to_uri, force_unicode -from django.utils.http import cookie_date -from django.http.multipartparser import MultiPartParser from django.conf import settings from django.core import signing from django.core.files import uploadhandler -from utils import * +from django.http.multipartparser import MultiPartParser +from django.http.utils import * +from django.utils.datastructures import MultiValueDict, ImmutableList +from django.utils.encoding import smart_str, iri_to_uri, force_unicode +from django.utils.http import cookie_date RESERVED_CHARS="!*'();:@&=+$,/?%#[]"