<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import re <EOL> from django . core . validators import EMPTY_VALUES <EOL> from django . forms import ValidationError <EOL> from django . forms . fields import Field , RegexField , Select <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from . at_states import STATE_CHOICES <EOL> re_ssn = re . compile ( r'<STR_LIT>' ) <EOL> class ATZipCodeField ( RegexField ) : <EOL> """<STR_LIT>""" <EOL> default_error_messages = { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } <EOL> def __init__ ( self , max_length = None , min_length = None , * args , ** kwargs ) : <EOL> super ( ATZipCodeField , self ) . __init__ ( r'<STR_LIT>' , <EOL> max_length , min_length , * args , ** kwargs ) <EOL> class ATStateSelect ( Select ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , attrs = None ) : <EOL> super ( ATStateSelect , self ) . __init__ ( attrs , choices = STATE_CHOICES ) <EOL> class ATSocialSecurityNumberField ( Field ) : <EOL> """<STR_LIT>""" <EOL> default_error_messages = { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } <EOL> def clean ( self , value ) : <EOL> value = super ( ATSocialSecurityNumberField , self ) . clean ( value ) <EOL> if value in EMPTY_VALUES : <EOL> return "<STR_LIT>" <EOL> if not re_ssn . search ( value ) : <EOL> raise ValidationError ( self . error_messages [ '<STR_LIT>' ] ) <EOL> sqnr , date = value . split ( "<STR_LIT:U+0020>" ) <EOL> sqnr , check = ( sqnr [ : <NUM_LIT:3> ] , ( sqnr [ <NUM_LIT:3> ] ) ) <EOL> if int ( sqnr ) < <NUM_LIT:100> : <EOL> raise ValidationError ( self . error_messages [ '<STR_LIT>' ] ) <EOL> res = ( int ( sqnr [ <NUM_LIT:0> ] ) * <NUM_LIT:3> + int ( sqnr [ <NUM_LIT:1> ] ) * <NUM_LIT:7> + int ( sqnr [ <NUM_LIT:2> ] ) * <NUM_LIT:9> + <EOL> int ( date [ <NUM_LIT:0> ] ) * <NUM_LIT:5> + int ( date [ <NUM_LIT:1> ] ) * <NUM_LIT:8> + int ( date [ <NUM_LIT:2> ] ) * <NUM_LIT:4> + <EOL> int ( date [ <NUM_LIT:3> ] ) * <NUM_LIT:2> + int ( date [ <NUM_LIT:4> ] ) * <NUM_LIT:1> + int ( date [ <NUM_LIT:5> ] ) * <NUM_LIT:6> ) <EOL> res = res % <NUM_LIT:11> <EOL> if res != int ( check ) : <EOL> raise ValidationError ( self . error_messages [ '<STR_LIT>' ] ) <EOL> return '<STR_LIT>' % ( sqnr , check , date ) </s>
