<s> """<STR_LIT>""" <EOL> from django . forms import ValidationError <EOL> from django . forms . fields import Field , RegexField , Select , EMPTY_VALUES <EOL> from django . utils . encoding import smart_unicode <EOL> from django . utils . translation import gettext <EOL> import re <EOL> class INZipCodeField ( RegexField ) : <EOL> default_error_messages = { <EOL> '<STR_LIT>' : gettext ( u'<STR_LIT>' ) , <EOL> } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( INZipCodeField , self ) . __init__ ( r'<STR_LIT>' , <EOL> max_length = None , min_length = None , * args , ** kwargs ) <EOL> class INStateField ( Field ) : <EOL> """<STR_LIT>""" <EOL> default_error_messages = { <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> } <EOL> def clean ( self , value ) : <EOL> from in_states import STATES_NORMALIZED <EOL> super ( INStateField , self ) . clean ( value ) <EOL> if value in EMPTY_VALUES : <EOL> return u'<STR_LIT>' <EOL> try : <EOL> value = value . strip ( ) . lower ( ) <EOL> except AttributeError : <EOL> pass <EOL> else : <EOL> try : <EOL> return smart_unicode ( STATES_NORMALIZED [ value . strip ( ) . lower ( ) ] ) <EOL> except KeyError : <EOL> pass <EOL> raise ValidationError ( self . error_messages [ '<STR_LIT>' ] ) <EOL> class INStateSelect ( Select ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , attrs = None ) : <EOL> from in_states import STATE_CHOICES <EOL> super ( INStateSelect , self ) . __init__ ( attrs , choices = STATE_CHOICES ) </s>
