<s> """<STR_LIT>""" <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 . encoding import smart_unicode <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> import re <EOL> phone_digits_re = re . compile ( r'<STR_LIT>' ) <EOL> class PTZipCodeField ( RegexField ) : <EOL> default_error_messages = { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( PTZipCodeField , self ) . __init__ ( r'<STR_LIT>' , <EOL> max_length = None , min_length = None , * args , ** kwargs ) <EOL> def clean ( self , value ) : <EOL> cleaned = super ( PTZipCodeField , self ) . clean ( value ) <EOL> if len ( cleaned ) == <NUM_LIT:7> : <EOL> return u'<STR_LIT>' % ( cleaned [ : <NUM_LIT:4> ] , cleaned [ <NUM_LIT:4> : ] ) <EOL> else : <EOL> return cleaned <EOL> class PTPhoneNumberField ( Field ) : <EOL> """<STR_LIT>""" <EOL> default_error_messages = { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } <EOL> def clean ( self , value ) : <EOL> super ( PTPhoneNumberField , self ) . clean ( value ) <EOL> if value in EMPTY_VALUES : <EOL> return u'<STR_LIT>' <EOL> value = re . sub ( '<STR_LIT>' , '<STR_LIT>' , smart_unicode ( value ) ) <EOL> m = phone_digits_re . search ( value ) <EOL> if m : <EOL> return u'<STR_LIT:%s>' % value <EOL> raise ValidationError ( self . error_messages [ '<STR_LIT>' ] ) </s>
